Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
When developing I use
@tool.ormcache_multi(multi=x) to gain performance.
From time to time I need to clean caches. For this I use
When we are in Gunicorn mode does
clean_caches notify all worker to automatically clean their own cache, or do I have to do some other calls? Is there some latency?
This is not really clear or maybe I missed some documentation.
Each registry (i.e. the
self.pool variable on any model instance) is kept in sync across workers through the database. Two sequences in database are used, one for the caches and one for the registry itself (e.g. to keep track of the fact a module has been installed), and each worker checks those sequences.
Whenever the sequences have a different value than what the worker was assuming, the workers will either clean their caches or reload the registry (thus loading any newly installed module, as it would have been flagged as "installed" in
The check on the sequences is done right when a new RPC call is done. Sequences are updated at the end of an RPC call. So there is some latency between a cache invalidation on a worker and the corresponding invalidation on another worker. But this is in fact ok: when the signaling occurs, it is itself part of the database transaction associated to the RPC call. Since the check is done right at the beginning of a new RPC call, that call/transaction will see correctly cleaned caches and updated registry.
See Guewen Baconnier's answer for the few places where the logic is implemented.
To have all that signaling occur, the
openerp.multi_process symbol must be set to True. This should be set in the configuration file used with Gunicorn or other WSGI servers.
In trunk, the
oe web command sets also
openerp.multi_process to True so that multiple
oe web processes can be run side by side.
From what I can read, when
clear_caches is called, it sets
_any_cache_cleared to true on the
This attribute is used to know if a model cache has been cleared so it can be signaled to the other processes (see
The check of signaling is done before each RPC request on models (
openerp.service.web_services.objects_proxy) or print of a report (
openerp.service.web_services.report_spool) and the signaling is done after the request or the print of the report.
ir.cron calls the check and signaling itself (
The signaling use a sequence in the database:
base_cache_signaling. Each time the sequence is increased, it means that the caches have to be cleared.
About This Community
This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 2/5/13, 10:23 AM|
|Seen: 11655 times|
|Last updated: 3/16/15, 8:10 AM|