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 <noreply@anthropic.com>
This commit is contained in:
2026-02-28 21:44:12 +01:00
parent c4d107206f
commit d07a308865
2 changed files with 8 additions and 2 deletions

3
db.py
View File

@@ -295,7 +295,10 @@ class ProjectDB:
self.conn.execute("COMMIT")
return df_id
except Exception:
try:
self.conn.execute("ROLLBACK")
except Exception:
pass
raise
# ------------------------------------------------------------------

View File

@@ -225,7 +225,10 @@ def sync_to_db(db, project_name: str, file_path: Path, data: dict) -> None:
db.conn.execute("COMMIT")
except Exception:
try:
db.conn.execute("ROLLBACK")
except Exception:
pass
raise
except Exception as e:
logger.warning(f"sync_to_db failed: {e}")