diff options
-rw-r--r-- | synapse/handlers/stats.py | 5 | ||||
-rw-r--r-- | synapse/storage/stats.py | 5 |
2 files changed, 6 insertions, 4 deletions
diff --git a/synapse/handlers/stats.py b/synapse/handlers/stats.py index 2f7c108181..8e1bf8b5d5 100644 --- a/synapse/handlers/stats.py +++ b/synapse/handlers/stats.py @@ -66,12 +66,13 @@ class StatsHandler(StateDeltasHandler): @defer.inlineCallbacks def process(): + yield lock.acquire() try: yield self._unsafe_process() finally: - lock.release() + yield lock.release() - if lock.acquire(blocking=False): + if not lock.locked: # we only want to run this process one-at-a-time, # and also, if the initial background updater wants us to keep out, # we should respect that. diff --git a/synapse/storage/stats.py b/synapse/storage/stats.py index ede5002fca..c9687c29d2 100644 --- a/synapse/storage/stats.py +++ b/synapse/storage/stats.py @@ -16,7 +16,8 @@ import logging from itertools import chain -from threading import Lock + +from twisted.internet.defer import DeferredLock from synapse.storage.state_deltas import StateDeltasStore from synapse.util.caches.descriptors import cached @@ -57,7 +58,7 @@ class StatsStore(StateDeltasStore): self.stats_enabled = hs.config.stats_enabled self.stats_bucket_size = hs.config.stats_bucket_size - self.stats_delta_processing_lock = Lock() + self.stats_delta_processing_lock = DeferredLock() self.register_noop_background_update("populate_stats_createtables") self.register_noop_background_update("populate_stats_process_rooms") |