RegistryManager: threading.RLock is missing
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Odoo Server (MOVED TO GITHUB) |
Fix Released
|
Low
|
OpenERP Publisher's Warranty Team |
Bug Description
Hi,
I just get caught by this bug, which is very hard to reproduce.
It happens only when:
- you have more than 1 thread which starts when a module is loaded
- a child thread calls openerp.
- OpenERP is started from an external script, like "behave" or "oe" when running the python tests (does not seems to happen when started from openerp-server)
It gives errors as this example:
File ".../server/
return fn(*params)
File ".../server/
res = security.login(db, login, password)
File ".../server/
return user_obj.login(db, login, password)
AttributeError: 'NoneType' object has no attribute 'login'
Cause:
RegistryManager
http://
It must be protected by cls.registries_lock because it may return the registry from cls.registries or create a new one.
What happens when there is no registry and 2 threads calls RegistryManager
1. they both have a KeyError
2. they both execute RegistryManager
3. the first thread create a new Registry. RegistryManager
4. then the second thread create a new Registry and replace the first one in cls.registries. RegistryManager
5. One of the registry (could not see which) has no models => self.pool.get() always returns None
If RegistryManager
The branch is coming.
Related branches
- Martin Trigaux (OpenERP) (community): Approve
-
Diff: 29 lines (+10/-9)1 file modifiedopenerp/modules/registry.py (+10/-9)
- OpenERP Core Team: Pending requested
-
Diff: 29 lines (+10/-9)1 file modifiedopenerp/modules/registry.py (+10/-9)
- OpenERP Community Backports: Pending requested
-
Diff: 29 lines (+10/-9)1 file modifiedopenerp/modules/registry.py (+10/-9)
description: | updated |
Changed in openobject-server: | |
assignee: | nobody → OpenERP Publisher's Warranty Team (openerp-opw) |
tags: | added: maintenance |
Changed in openobject-server: | |
status: | New → Confirmed |
importance: | Undecided → Low |
no longer affects: | ocb-server |
Hello Guewen,
We confirm this could happened and it should be fixed with the lock (we could not reproduce but the analysis seems to confirm it).
We used to have a lock on the get method but it was removed due to deadlock possibilities. This is no longer possible with the current code so we can put the lock back. See my commit message for more information.
revno: 5129 [merge]
revision-id: <email address hidden>
Thanks for the patch