Skip to content
Snippets Groups Projects
Commit 63ccaa58 authored by Richard van der Hoff's avatar Richard van der Hoff
Browse files

Avoid retrying forever on IntegrityError

parent 79eba878
No related branches found
No related tags found
No related merge requests found
......@@ -495,6 +495,7 @@ class SQLBaseStore(object):
Deferred(bool): True if a new entry was created, False if an
existing one was updated.
"""
attempts = 0
while True:
try:
result = yield self.runInteraction(
......@@ -504,6 +505,12 @@ class SQLBaseStore(object):
)
defer.returnValue(result)
except self.database_engine.module.IntegrityError as e:
attempts += 1
if attempts >= 5:
# don't retry forever, because things other than races
# can cause IntegrityErrors
raise
# presumably we raced with another transaction: let's retry.
logger.warn(
"IntegrityError when upserting into %s; retrying: %s",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment