diff --git a/common_py/src/videoag_common/database/database.py b/common_py/src/videoag_common/database/database.py index 9b362494991f51669fe1319dd7227af87fdcb219..a208f2e8495a3e180ab7c56f7bb0a4e1517e8828 100644 --- a/common_py/src/videoag_common/database/database.py +++ b/common_py/src/videoag_common/database/database.py @@ -220,9 +220,11 @@ class Database: if attempts >= (self._max_write_attempts if writeable else self._max_read_attempts): self._on_transaction_aborted_after_repeated_conflict(writeable) raise TransactionConflictError(e) + # Sleep a random time for up to 500ms to increase chance that next attempt succeeds (The randomness makes # it more likely that we reattempt at a different time than the one with which we are in conflict right now) time.sleep(random.random() / 2) + print("Warning: Reattempting transaction after commit conflict") continue raise AssertionError("This should be unreachable code")