[PATCH b4 27/27] review: close the tracking database when archiving fails

Christian Brauner <[email protected]> Fri, 31 Jul 2026 11:21:26 +0200
Newsgroups org.kernel.linux.tools
Message-ID <20260731-work-b4-editor-branch-guard-v1-27-de68a7c8e4cb@kernel.org>
Same thing the auto-mark block had a few patches ago: the connection is
closed in the last statement of the try, so a failing update_series_status()
skips the close and leaks it. The tracking UI archives from a process that
stays around for the rest of the session.

Close it in a finally instead.

Signed-off-by: Christian Brauner (Amutable) <[email protected]>
---
 src/b4/review/_review.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/b4/review/_review.py b/src/b4/review/_review.py
index 4c67387..fb308bd 100644
--- a/src/b4/review/_review.py
+++ b/src/b4/review/_review.py
@@ -875,14 +875,17 @@ def archive_series(
             return False, err
 
     # Update tracking database
+    conn = None
     try:
         conn = b4.review.tracking.get_db(identifier)
         b4.review.tracking.update_series_status(
             conn, change_id, 'archived', revision=revision
         )
-        conn.close()
     except Exception as ex:
         return False, f'DB error: {ex}'
+    finally:
+        if conn is not None:
+            conn.close()
 
     # Mark as archived in Patchwork.  The local archive is already done and
     # cannot be retried, so a Patchwork hiccup is a warning, not a failure.

-- 
2.53.0