summary refs log tree commit diff
diff options
context:
space:
mode:
authorreivilibre <oliverw@matrix.org>2022-05-18 13:57:59 +0000
committerGitHub <noreply@github.com>2022-05-18 13:57:59 +0000
commit635f0d916bc5155d3f3cba0389a1ebe08a6b5910 (patch)
tree1d84bb54113d720791f6020c38c202eebdfe6e7b
parentGive a meaningful error message when a client tries to create a room with an ... (diff)
downloadsynapse-635f0d916bc5155d3f3cba0389a1ebe08a6b5910.tar.xz
Do not keep going if there are 5 back-to-back background update failures. (#12781)
-rw-r--r--changelog.d/12781.misc1
-rw-r--r--synapse/storage/background_updates.py8
2 files changed, 9 insertions, 0 deletions
diff --git a/changelog.d/12781.misc b/changelog.d/12781.misc
new file mode 100644
index 0000000000..8a04571617
--- /dev/null
+++ b/changelog.d/12781.misc
@@ -0,0 +1 @@
+Do not keep going if there are 5 back-to-back background update failures.
\ No newline at end of file
diff --git a/synapse/storage/background_updates.py b/synapse/storage/background_updates.py
index c2bbbb574e..37f2d6c644 100644
--- a/synapse/storage/background_updates.py
+++ b/synapse/storage/background_updates.py
@@ -282,12 +282,20 @@ class BackgroundUpdater:
 
         self._running = True
 
+        back_to_back_failures = 0
+
         try:
             logger.info("Starting background schema updates")
             while self.enabled:
                 try:
                     result = await self.do_next_background_update(sleep)
+                    back_to_back_failures = 0
                 except Exception:
+                    back_to_back_failures += 1
+                    if back_to_back_failures >= 5:
+                        raise RuntimeError(
+                            "5 back-to-back background update failures; aborting."
+                        )
                     logger.exception("Error doing update")
                 else:
                     if result: