IllegalUseOfScopeReplacer on concurrent initial requests

Bug #716770 reported by John A Meinel
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Bazaar
Confirmed
Low
Unassigned
loggerhead
Triaged
Critical
Unassigned

Bug Description

When you first start up a loggerhead instance, none of the lazy_imports have been triggered.
If you get 2 concurrent requests right away, then it is possible for them to trigger IllegalUseOfScopeReplacer.

A simple way to demonstrate this is:

 bzr serve --http &
 # wait for it to start
 wget http://localhost:8080/changes & wget http://localhost:8080/changes

The traceback is often different, because it depends on where the two threads become synchronized on importing the same lazy import.

One very quick workaround for it is to just issue a single request after startup, triggering 99% of the lazy imports to be triggered that will normally ever be triggered.

I'll also include bzr as part of the bug. This is because LazyImports aren't particularly compatible with multi-threading, but only loggerhead really stresses multithreading with bzrlib.

Considering this low importance, because it only really triggers immediately when loggerhead is started. Once it has served a request, most imports will already be triggered.

Tags: oops
Revision history for this message
John A Meinel (jameinel) wrote :

Confirming that lazy_imports don't play well with multi-threading. It might be nice if we had some sort of flag that allowed the scope replacer objects to proxy, or possibly disable lazy importing entirely for a given command. Though because of circular imports, we probably can't disable it 100%.

Changed in bzr:
importance: Undecided → Low
status: New → Confirmed
Gavin Panella (allenap)
Changed in loggerhead:
status: Confirmed → Triaged
Revision history for this message
Diogo Matsubara (matsubara) wrote :

It looks like OOPS-2021CBA2 is related to this issue. Could someone confirm that?

tags: added: oops
Revision history for this message
Robert Collins (lifeless) wrote :

confirmed.

Changed in loggerhead:
importance: Low → Critical
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.