Merge lp:~camptocamp/ocb-server/7.0-registrymanager-rlock-1238560-gbr into lp:ocb-server

Proposed by Guewen Baconnier @ Camptocamp
Status: Rejected
Rejected by: Guewen Baconnier @ Camptocamp
Proposed branch: lp:~camptocamp/ocb-server/7.0-registrymanager-rlock-1238560-gbr
Merge into: lp:ocb-server
Diff against target: 29 lines (+10/-9)
1 file modified
openerp/modules/registry.py (+10/-9)
To merge this branch: bzr merge lp:~camptocamp/ocb-server/7.0-registrymanager-rlock-1238560-gbr
Reviewer Review Type Date Requested Status
OpenERP Community Backports Pending
Review via email: mp+193749@code.launchpad.net

Commit message

[FIX] missing a threading.RLock in RegistryManager.get():

if no registry exists and several calls to RegistryManager.get() are called at the same time
by several threads, several registries will be created one after the other and only the last
one will be kept in cls.registries

Description of the change

Fixes lp:1238560

Details on the bug report.

To post a comment you must log in.
Revision history for this message
Stéphane Bidoul (Acsone) (sbi) wrote :

The lock seems mandatory to me too.

Is the get() method called frequently enough to warrant a double checked locking pattern in order to improve performance?

Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

It has been merged in the 7.0 branch, so we don't need to merge it here.

revno: 5129 [merge]
revision-id: <email address hidden>

Unmerged revisions

5137. By Guewen Baconnier @ Camptocamp

[FIX] missing a threading.RLock in RegistryManager.get():

if no registry exists and several calls to RegistryManager.get() are called at the same time
by several threads, several registries will be created one after the other and only the last
one will be kept in cls.registries

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openerp/modules/registry.py'
2--- openerp/modules/registry.py 2013-10-11 12:39:14 +0000
3+++ openerp/modules/registry.py 2013-11-04 11:00:43 +0000
4@@ -185,15 +185,16 @@
5 @classmethod
6 def get(cls, db_name, force_demo=False, status=None, update_module=False):
7 """ Return a registry for a given database name."""
8- try:
9- return cls.registries[db_name]
10- except KeyError:
11- return cls.new(db_name, force_demo, status,
12- update_module)
13- finally:
14- # set db tracker - cleaned up at the WSGI
15- # dispatching phase in openerp.service.wsgi_server.application
16- threading.current_thread().dbname = db_name
17+ with cls.registries_lock:
18+ try:
19+ return cls.registries[db_name]
20+ except KeyError:
21+ return cls.new(db_name, force_demo, status,
22+ update_module)
23+ finally:
24+ # set db tracker - cleaned up at the WSGI
25+ # dispatching phase in openerp.service.wsgi_server.application
26+ threading.current_thread().dbname = db_name
27
28 @classmethod
29 def new(cls, db_name, force_demo=False, status=None,

Subscribers

People subscribed via source and target branches

to status/vote changes: