[Buildbot-commits] [Buildbot] #2162: Getting exceptions.KeyError on console webpage because of a weakref

Buildbot nobody at buildbot.net
Wed Dec 7 11:54:24 UTC 2011


#2162: Getting exceptions.KeyError on console webpage because of a weakref
---------------------+-----------------------
Reporter:  JocelynJ  |      Owner:
    Type:  defect    |     Status:  new
Priority:  major     |  Milestone:  undecided
 Version:  0.8.5     |   Keywords:  web
---------------------+-----------------------
 Hi,

 I'm getting the following error on a 0.8.5 instance of buildbot. It
 happens almost everyday when I keep a tab in my browser on the
 http://xxx/console url. Full trackback is included with this ticket, but
 here is my analysis of the issue.

 The bug seems to happen here:

           File
 ".../buildbot-0.8.5/lib/python/buildbot-0.8.5-py2.6.egg/buildbot/status/builder.py",
 line 211, in getBuildByNumber
             return self.touchBuildCache(self.buildCache[number])
           File ".../python/2.6.5/rhe5-x86_64/lib/python2.6/weakref.py",
 line 54, in __getitem__
             o = self.data[key]()

 According to the code, it is in this part:

         if number in self.buildCache:
             metrics.MetricCountEvent.log("buildCache.hits", 1)
             return self.touchBuildCache(self.buildCache[number])

 I think it is not thread-safe, because self.buildCache[number] could be
 removed (as it is a weakref) between the if and the return. If my analysis
 is correct, the following (not-tested) code should fix the issue:

          try:
              item = self.touchBuildCache(self.buildCache[number])
              metrics.MetricCountEvent.log("buildCache.hits", 1)
              return item
          except KeyError:
              metrics.MetricCountEvent.log("buildCache.misses", 1)


 Do you think it is correct ?

 If you need more information, I can try to provide them, but please note
 that it is a private instance, and it might be difficult to clean the
 configuration file to remove the "sensitive" parts. Logs can be provided
 too, but I didn't find anything interesting inside.

 Thanks,
 Jocelyn

-- 
Ticket URL: <http://trac.buildbot.net/ticket/2162>
Buildbot <http://buildbot.net/>
Buildbot: build/test automation


More information about the Commits mailing list