mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-10 02:24:35 +08:00
fix(storage): handle rollback failures in batch operations
Adds nested exception handling in add_files() and _migrate_fts_to_external() to catch and log rollback failures. Uses exception chaining to preserve both transaction and rollback errors, preventing silent database inconsistency. Solution-ID: SOL-1735385400010 Issue-ID: ISS-1766921318981-10 Task-ID: T1
This commit is contained in:
@@ -330,8 +330,14 @@ class SQLiteStore:
|
||||
)
|
||||
|
||||
conn.commit()
|
||||
except Exception:
|
||||
conn.rollback()
|
||||
except Exception as exc:
|
||||
try:
|
||||
conn.rollback()
|
||||
except Exception as rollback_exc:
|
||||
logger.error(
|
||||
"Rollback failed after add_files() error (%s): %s", exc, rollback_exc
|
||||
)
|
||||
raise exc.with_traceback(exc.__traceback__) from rollback_exc
|
||||
raise
|
||||
|
||||
def remove_file(self, path: str | Path) -> bool:
|
||||
@@ -619,11 +625,14 @@ class SQLiteStore:
|
||||
conn.execute("INSERT INTO files_fts(files_fts) VALUES('rebuild')")
|
||||
conn.execute("DROP TABLE files_fts_legacy")
|
||||
conn.commit()
|
||||
except sqlite3.DatabaseError:
|
||||
except sqlite3.DatabaseError as exc:
|
||||
try:
|
||||
conn.rollback()
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as rollback_exc:
|
||||
logger.error(
|
||||
"Rollback failed during FTS schema migration (%s): %s", exc, rollback_exc
|
||||
)
|
||||
raise exc.with_traceback(exc.__traceback__) from rollback_exc
|
||||
|
||||
try:
|
||||
conn.execute("DROP TABLE IF EXISTS files_fts")
|
||||
|
||||
Reference in New Issue
Block a user