RuntimeError from get_transport when another thread concurrently registers a new transport

Bug #430509 reported by Andrew Bennetts
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Bazaar
Confirmed
Low
Unassigned

Bug Description

Traceback from vila:

ERROR: bzrlib.tests.test_http.SmartHTTPTunnellingTest.test_open_bzrdir(urllib,HTTP/1.1) (subunit.RemotedTestCase)
----------------------------------------------------------------------
RemoteException: Traceback (most recent call last):
  File "/home/babune/buildbot/bzr/slaves/gentoo/tests/gentoo/build/bzrlib/tests/test_http.py", line 1770, in test_open_bzrdir
    bd = bzrdir.BzrDir.open(url)
  File "/home/babune/buildbot/bzr/slaves/gentoo/tests/gentoo/build/bzrlib/bzrdir.py", line 843, in open
    t = get_transport(base, possible_transports=possible_transports)
  File "/home/babune/buildbot/bzr/slaves/gentoo/tests/gentoo/build/bzrlib/transport/__init__.py", line 1585, in get_transport
    for proto, factory_list in transport_list_registry.items():
  File "/home/babune/buildbot/bzr/slaves/gentoo/tests/gentoo/build/bzrlib/registry.py", line 225, in items
    return sorted(self.iteritems())
  File "/home/babune/buildbot/bzr/slaves/gentoo/tests/gentoo/build/bzrlib/registry.py", line 221, in iteritems
    for key, getter in self._dict.iteritems():
RuntimeError: dictionary changed size during iteration

This is a smart-server-over-http test. Probably what is happening is that while the main thread is doing get_transport, the server thread is registering a ChrootTransport. It's conceivable that similar situations might happen with some real bzr+http server deployments, so in theory it's more than just an intermittent test bug.

The right fix is presumably to use self._dict.items() in Registry. We should try to write a test that triggers this race somehow, probably by adding a lazy registration that will add something to its registry, then calling Registry.iteritems().

This also implies that Registry.iteritems() should perhaps be deprecated, because it won't actually be incremental anymore. But probably that doesn't matter.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.