feat: add temp-file swap to BigQuery extractor
Write to extract.duckdb.tmp, then atomically swap into place with WAL cleanup. Prevents lock conflicts with orchestrator holding read lock on existing database.
This commit is contained in:
parent
f25393871d
commit
1488e01bf9
1 changed files with 12 additions and 0 deletions
|
|
@ -112,6 +112,18 @@ def init_extract(
|
|||
finally:
|
||||
conn.close()
|
||||
|
||||
# Atomic swap with WAL cleanup
|
||||
old_wal = Path(str(db_path) + ".wal")
|
||||
if old_wal.exists():
|
||||
old_wal.unlink()
|
||||
|
||||
if tmp_db_path.exists():
|
||||
shutil.move(str(tmp_db_path), str(db_path))
|
||||
|
||||
tmp_wal = Path(str(tmp_db_path) + ".wal")
|
||||
if tmp_wal.exists():
|
||||
tmp_wal.unlink()
|
||||
|
||||
return stats
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue