summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorShay <hillerys@element.io>2022-03-07 09:44:33 -0800
committerGitHub <noreply@github.com>2022-03-07 09:44:33 -0800
commit26211fec24d8d0a967de33147e148166359ec8cb (patch)
tree0524adab52f6da8693122bf3aebd6e9972fb071e /synapse
parentInvalidate caches when an event with a relation is redacted. (#12121) (diff)
downloadsynapse-26211fec24d8d0a967de33147e148166359ec8cb.tar.xz
Fix a bug in background updates wherein background updates are never run using the default batch size (#12157)
Diffstat (limited to 'synapse')
-rw-r--r--synapse/storage/background_updates.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/synapse/storage/background_updates.py b/synapse/storage/background_updates.py
index d64910aded..4acc2c997d 100644
--- a/synapse/storage/background_updates.py
+++ b/synapse/storage/background_updates.py
@@ -102,10 +102,12 @@ class BackgroundUpdatePerformance:
         Returns:
             A duration in ms as a float
         """
-        if self.avg_duration_ms == 0:
-            return 0
-        elif self.total_item_count == 0:
+        # We want to return None if this is the first background update item
+        if self.total_item_count == 0:
             return None
+        # Avoid dividing by zero
+        elif self.avg_duration_ms == 0:
+            return 0
         else:
             # Use the exponential moving average so that we can adapt to
             # changes in how long the update process takes.