[FIX] race condition in RegistryManager
authorXavier Morel <xmo@openerp.com>
Fri, 16 Sep 2011 07:52:27 +0000 (09:52 +0200)
committerXavier Morel <xmo@openerp.com>
Fri, 16 Sep 2011 07:52:27 +0000 (09:52 +0200)
commit556a17d5bc14adb77b6eef95a9fee9c049b9af8d
tree5a70acaa1be24f4f096ab6c42debb4b4260f7626
parent6283e78aaf19d95e3bdc37bfb621446573e56512
[FIX] race condition in RegistryManager

When two requests arrive simultanously for the same uninitialized db,
the first request starts the db initialization, but the second one
immediately gets the partially uninitialized registry (actually just
created, so generally completely uninitialized), leading to an access
error in later code (as soon as a registry object is accessed).

Add a GRML (Global RegistryManager Lock) to ensure the RegistryManager
*never* returns a partially initialized registry.

The current implementation is simple (just lock all RegistryManager
methods before they manipulate registries), but overly broad. This is
an area which might be optimizable if there are perf/responsivity
issues (e.g. each Registry instance could have a lock, and the
RegistryManager would grab the instance's, allowing the inititlization
of registry A not to block registry B from being returned in heavily
concurrent uses).

However this is not an issue in multiprocessing scenarios, which are
being planned for the near future. So for now, being correct is
probably the best idea.

bzr revid: xmo@openerp.com-20110916075227-0zutzlxn2dcd94c4
openerp/modules/registry.py