Skip to content

Commit

Permalink
Retry on TransactionError when attempting to commit (#299)
Browse files Browse the repository at this point in the history
Serialization errors can be generated at commit time and should be
retried.
  • Loading branch information
msullivan authored Feb 21, 2022
1 parent 878cd3e commit f1bf68d
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions edgedb/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,18 @@ async def _exit(self, extype, ex):
if ex is None:
# On commit we don't know if commit is succeeded before the
# database have received it or after it have been done but
# network is dropped before we were able to receive a response
# TODO(tailhook) retry on some errors
raise err
# network is dropped before we were able to receive a response.
# On a TransactionError, though, we know the we need
# to retry.
# TODO(tailhook) should other errors have retries?
if (
isinstance(err, errors.TransactionError)
and err.has_tag(errors.SHOULD_RETRY)
and self.__retry._retry(err)
):
pass
else:
raise err
# If we were going to rollback, look at original error
# to find out whether we want to retry, regardless of
# the rollback error.
Expand Down

0 comments on commit f1bf68d

Please sign in to comment.