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:
5
db.py
5
db.py
@@ -295,7 +295,10 @@ class ProjectDB:
|
|||||||
self.conn.execute("COMMIT")
|
self.conn.execute("COMMIT")
|
||||||
return df_id
|
return df_id
|
||||||
except Exception:
|
except Exception:
|
||||||
self.conn.execute("ROLLBACK")
|
try:
|
||||||
|
self.conn.execute("ROLLBACK")
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
raise
|
raise
|
||||||
|
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
|
|||||||
5
utils.py
5
utils.py
@@ -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:
|
||||||
db.conn.execute("ROLLBACK")
|
try:
|
||||||
|
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