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

Commit

Permalink
Do not keep going if there are 5 back-to-back background update failu…
Browse files Browse the repository at this point in the history
…res. (#12781)
  • Loading branch information
reivilibre authored May 18, 2022
1 parent df49635 commit 635f0d9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.d/12781.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Do not keep going if there are 5 back-to-back background update failures.
8 changes: 8 additions & 0 deletions synapse/storage/background_updates.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,12 +282,20 @@ async def run_background_updates(self, sleep: bool) -> None:

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:
Expand Down

0 comments on commit 635f0d9

Please sign in to comment.