From 76c8d3f752716c858bd1a8a1cb1488c5e499dbb0 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 01:44:24 +0200
Subject: [PATCH] Log exception on database commit conflict

---
 common_py/src/videoag_common/database/database.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common_py/src/videoag_common/database/database.py b/common_py/src/videoag_common/database/database.py
index f8b2678..079c9b7 100644
--- a/common_py/src/videoag_common/database/database.py
+++ b/common_py/src/videoag_common/database/database.py
@@ -2,6 +2,7 @@ import os
 import random
 import sys
 import time
+import traceback
 from enum import StrEnum
 from typing import Callable, TypeVar, TypeVarTuple, Sequence
 
@@ -224,7 +225,8 @@ class Database:
                 # 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", e)
+                print("Warning: Reattempting transaction after commit conflict", file=sys.stderr)
+                traceback.print_exception(e)
                 continue
                 
         raise AssertionError("This should be unreachable code")
-- 
GitLab