From 3862c03ec27badef167acfc96c4f066ff14f0682 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Fri, 26 Jan 2018 18:31:50 +0100 Subject: [PATCH] [FIX] base: honor registry/cache signaling for multiple threaded servers Before this patch the registry and cache signaling was only activated for PreforkServer. In case Odoo was deployed in a multi process/multi threaded architecture the signaling was not ensured, causing registry de-synchronisation amongst threaded servers. Backported from fd4939dc7865f5cbe06e47f423961219ffe1379e --- odoo/modules/registry.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/odoo/modules/registry.py b/odoo/modules/registry.py index 0ccf793aedd..7defc2744f4 100644 --- a/odoo/modules/registry.py +++ b/odoo/modules/registry.py @@ -130,7 +130,7 @@ class Registry(Mapping): self.loaded = False # whether all modules are loaded self.ready = False # whether everything is set up - # Inter-process signaling (used only when odoo.multi_process is True): + # Inter-process signaling: # The `base_registry_signaling` sequence indicates the whole registry # must be reloaded. # The `base_cache_signaling sequence` indicates all caches must be @@ -358,7 +358,7 @@ class Registry(Mapping): def setup_signaling(self): """ Setup the inter-process signaling on this registry. """ - if not odoo.multi_process: + if self.in_test_mode(): return with self.cursor() as cr: @@ -384,7 +384,7 @@ class Registry(Mapping): """ Check whether the registry has changed, and performs all necessary operations to update the registry. Return an up-to-date registry. """ - if not odoo.multi_process: + if self.in_test_mode(): return self with closing(self.cursor()) as cr: @@ -410,7 +410,7 @@ class Registry(Mapping): def signal_changes(self): """ Notifies other processes if registry or cache has been invalidated. """ - if odoo.multi_process and self.registry_invalidated: + if self.registry_invalidated and not self.in_test_mode(): _logger.info("Registry changed, signaling through the database") with closing(self.cursor()) as cr: cr.execute("select nextval('base_registry_signaling')") @@ -418,7 +418,7 @@ class Registry(Mapping): # no need to notify cache invalidation in case of registry invalidation, # because reloading the registry implies starting with an empty cache - elif odoo.multi_process and self.cache_invalidated: + elif self.cache_invalidated and not self.in_test_mode(): _logger.info("At least one model cache has been invalidated, signaling through the database.") with closing(self.cursor()) as cr: cr.execute("select nextval('base_cache_signaling')")