diff options
author | Richard van der Hoff <github@rvanderhoff.org.uk> | 2017-11-27 12:19:35 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-27 12:19:35 +0000 |
commit | 84b31a3e7a9e74dc009cf39c9d342cb317d977f0 (patch) | |
tree | c88b29825ecf2fbbf9330eee74bba9ef01c3eece | |
parent | Merge pull request #2711 from matrix-org/rav/fix_dns_errhandler (diff) | |
parent | Avoid retrying forever on IntegrityError (diff) | |
download | synapse-84b31a3e7a9e74dc009cf39c9d342cb317d977f0.tar.xz |
Merge pull request #2713 from matrix-org/rav/no_upsert_forever
Avoid retrying forever on IntegrityError
-rw-r--r-- | synapse/storage/_base.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/synapse/storage/_base.py b/synapse/storage/_base.py index e6eefdd6fe..662c30187d 100644 --- a/synapse/storage/_base.py +++ b/synapse/storage/_base.py @@ -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", |