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:
1 parent
c4d107206f
commit
d07a308865
2 files changed
+6
No files matched your search
@@ -295,7 +295,10 @@ class ProjectDB:
|
|||||||
self.conn.execute("COMMIT")
|
self.conn.execute("COMMIT")
|
||||||
return df_id
|
return df_id
|
||||||
except Exception:
|
except Exception:
|
||||||
|
try:
|
||||||
self.conn.execute("ROLLBACK")
|
self.conn.execute("ROLLBACK")
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
raise
|
raise
|
||||||
|
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
|
|||||||
@@ -225,7 +225,10 @@ def sync_to_db(db, project_name: str, file_path: Path, data: dict) -> None:
|
|||||||
|
|
||||||
db.conn.execute("COMMIT")
|
db.conn.execute("COMMIT")
|
||||||
except Exception:
|
except Exception:
|
||||||
|
try:
|
||||||
db.conn.execute("ROLLBACK")
|
db.conn.execute("ROLLBACK")
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
raise
|
raise
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning(f"sync_to_db failed: {e}")
|
logger.warning(f"sync_to_db failed: {e}")
|
||||||
|
|||||||
Reference in new issue
Block a user