Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 635f0d9

Browse files
authored
Do not keep going if there are 5 back-to-back background update failures. (#12781)
1 parent df49635 commit 635f0d9

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

changelog.d/12781.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Do not keep going if there are 5 back-to-back background update failures.

synapse/storage/background_updates.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,12 +282,20 @@ async def run_background_updates(self, sleep: bool) -> None:
282282

283283
self._running = True
284284

285+
back_to_back_failures = 0
286+
285287
try:
286288
logger.info("Starting background schema updates")
287289
while self.enabled:
288290
try:
289291
result = await self.do_next_background_update(sleep)
292+
back_to_back_failures = 0
290293
except Exception:
294+
back_to_back_failures += 1
295+
if back_to_back_failures >= 5:
296+
raise RuntimeError(
297+
"5 back-to-back background update failures; aborting."
298+
)
291299
logger.exception("Error doing update")
292300
else:
293301
if result:

0 commit comments

Comments
 (0)