From 3f385f0f97c5bf2475d2ab2968b4109836eede0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20K=C3=BCnzel?= <simonk@fsmpi.rwth-aachen.de> Date: Fri, 2 May 2025 00:41:29 +0200 Subject: [PATCH] Add warning for database conflicts --- common_py/src/videoag_common/database/database.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/common_py/src/videoag_common/database/database.py b/common_py/src/videoag_common/database/database.py index 9b36249..a208f2e 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") -- GitLab