~acsone-openerp/openobject-server/7.0-bug-1076541

« back to all changes in this revision

Viewing changes to openerp/modules/registry.py

  • Committer: Denis Ledoux
  • Author(s): Olivier Dony
  • Date: 2014-01-16 15:11:57 UTC
  • Revision ID: dle@openerp.com-20140116151157-3zlyrg48xqn2lkd0
[FIX] modules: set initial values for multi-process signaling to None to avoid missing events

For fresh databases, the signaling sequences in the
database stays at 1 until the installation of the
first module. If several workers are hit for this
database before the first module is installed,
this database registry will be loaded with a signaling
sequence of 1. Since  was the default value, any
signal received by workers in this state was ignored 
because they thought the registry was previously
not loaded.
Using None to indicate an  sequence value
is more accurate and avoids this error

Show diffs side-by-side

added added

removed removed

Lines of Context:
66
66
        # must be reloaded.
67
67
        # The `base_cache_signaling sequence` indicates all caches must be
68
68
        # invalidated (i.e. cleared).
69
 
        self.base_registry_signaling_sequence = 1
70
 
        self.base_cache_signaling_sequence = 1
 
69
        self.base_registry_signaling_sequence = None
 
70
        self.base_cache_signaling_sequence = None
71
71
 
72
72
        # Flag indicating if at least one model cache has been cleared.
73
73
        # Useful only in a multi-process context.
283
283
                           base_cache_signaling.last_value
284
284
                    FROM base_registry_signaling, base_cache_signaling""")
285
285
                r, c = cr.fetchone()
 
286
                _logger.debug("Multiprocess signaling check: [Registry - old# %s new# %s] "\
 
287
                    "[Cache - old# %s new# %s]",
 
288
                    registry.base_registry_signaling_sequence, r,
 
289
                    registry.base_cache_signaling_sequence, c)
286
290
                # Check if the model registry must be reloaded (e.g. after the
287
291
                # database has been updated by another process).
288
 
                if registry.base_registry_signaling_sequence > 1 and registry.base_registry_signaling_sequence != r:
 
292
                if registry.base_registry_signaling_sequence is not None and registry.base_registry_signaling_sequence != r:
289
293
                    _logger.info("Reloading the model registry after database signaling.")
290
294
                    registry = cls.new(db_name)
291
295
                # Check if the model caches must be invalidated (e.g. after a write
292
296
                # occured on another process). Don't clear right after a registry
293
297
                # has been reload.
294
 
                elif registry.base_cache_signaling_sequence > 1 and registry.base_cache_signaling_sequence != c:
 
298
                elif registry.base_cache_signaling_sequence is not None and registry.base_cache_signaling_sequence != c:
295
299
                    _logger.info("Invalidating all model caches after database signaling.")
296
300
                    registry.clear_caches()
297
301
                    registry.reset_any_cache_cleared()
328
332
    @classmethod
329
333
    def signal_registry_change(cls, db_name):
330
334
        if openerp.multi_process and db_name in cls.registries:
 
335
            _logger.info("Registry changed, signaling through the database")
331
336
            registry = cls.get(db_name)
332
337
            cr = registry.db.cursor()
333
338
            r = 1