From d07a30886576caf1b0bef79dba4021e0db6a6830 Mon Sep 17 00:00:00 2001 From: Ethanfel Date: Sat, 28 Feb 2026 21:44:12 +0100 Subject: [PATCH] Harden ROLLBACK against I/O errors in transactions If the original error (e.g., disk full) also prevents ROLLBACK from executing, catch and suppress the ROLLBACK failure so the original exception propagates cleanly and the connection isn't left in a permanently broken state. Co-Authored-By: Claude Opus 4.6 --- db.py | 5 ++++- utils.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/db.py b/db.py index 000f577..cf428e5 100644 --- a/db.py +++ b/db.py @@ -295,7 +295,10 @@ class ProjectDB: self.conn.execute("COMMIT") return df_id except Exception: - self.conn.execute("ROLLBACK") + try: + self.conn.execute("ROLLBACK") + except Exception: + pass raise # ------------------------------------------------------------------ diff --git a/utils.py b/utils.py index 805ec79..af80c60 100644 --- a/utils.py +++ b/utils.py @@ -225,7 +225,10 @@ def sync_to_db(db, project_name: str, file_path: Path, data: dict) -> None: db.conn.execute("COMMIT") except Exception: - db.conn.execute("ROLLBACK") + try: + db.conn.execute("ROLLBACK") + except Exception: + pass raise except Exception as e: logger.warning(f"sync_to_db failed: {e}")