Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions src/sirchmunk/storage/duckdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,19 +119,17 @@ def _checkpoint_wal(db_file: str):
logger.info(
f"Stale WAL detected at {wal_file}, checkpointing before load"
)
tmp_conn = None
try:
tmp_conn = duckdb.connect(db_file)
tmp_conn.execute("CHECKPOINT")
tmp_conn.close()
logger.info(f"WAL checkpoint completed for {db_file}")
except Exception as e:
logger.warning(f"WAL checkpoint failed for {db_file}: {e}")
# Last resort: remove the stale WAL so READ_ONLY ATTACH can proceed
try:
wal_file.unlink()
logger.info(f"Removed stale WAL file {wal_file}")
except Exception:
pass
logger.error(f"WAL checkpoint failed for {db_file}: {e}")
raise
finally:
if tmp_conn is not None:
tmp_conn.close()

@staticmethod
def _cleanup_wal(db_file: str):
Expand Down