[FIX] registry: avoid discarding registry or cache when the registry is fresh

When the sequence value is 1 it means that either:
 - the registry was just instantiated, so there is no
   reason to reload it immediately, the real checks will
   start at next request
 - the db was just created with new sequences set to 1,
   so there has been no change to reload

In both cases there is no good reason to reload the
registry, and it is actually a performance killer,
especially for cron workers that keep iterating on
the list of databases.

bzr revid: odo@openerp.com-20131011100313-4bud8e9xq2afp9z7
This commit is contained in:
Olivier Dony 2013-10-11 12:03:13 +02:00
parent dafa12d92c
commit 78579d289b
1 changed files with 4 additions and 4 deletions

View File

@ -284,16 +284,14 @@ class RegistryManager(object):
r, c = cr.fetchone()
# Check if the model registry must be reloaded (e.g. after the
# database has been updated by another process).
if registry.base_registry_signaling_sequence != r:
if registry.base_registry_signaling_sequence > 1 and registry.base_registry_signaling_sequence != r:
_logger.info("Reloading the model registry after database signaling.")
registry = cls.new(db_name)
registry.base_registry_signaling_sequence = r
# Check if the model caches must be invalidated (e.g. after a write
# occured on another process). Don't clear right after a registry
# has been reload.
elif registry.base_cache_signaling_sequence != c:
if registry.base_cache_signaling_sequence > 1 and registry.base_cache_signaling_sequence != c:
_logger.info("Invalidating all model caches after database signaling.")
registry.base_cache_signaling_sequence = c
registry.clear_caches()
registry.reset_any_cache_cleared()
# One possible reason caches have been invalidated is the
@ -303,6 +301,8 @@ class RegistryManager(object):
for column in model._columns.values():
if hasattr(column, 'digits_change'):
column.digits_change(cr)
registry.base_registry_signaling_sequence = r
registry.base_cache_signaling_sequence = c
finally:
cr.close()