fix(FN-5407): stop checkpoint-truncating live DB during backup
Backups opened a second node:sqlite connection against the live fusion.db and ran PRAGMA wal_checkpoint(TRUNCATE) before copying. A node:sqlite SIGSEGV mid-checkpoint (the recurring pager_write crash noted in db.ts) could leave the main DB file extended-but-zeroed, which is exactly the failure mode that wiped a 1GB fusion.db tonight. Replace the in-process checkpoint with a plain cp of the main DB plus any sibling -wal/-shm files. SQLite replays the WAL on first open, so uncheckpointed pages survive without us ever opening a second connection against the live database. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
5
.changeset/fix-fn-5407-backup-checkpoint-truncate.md
Normal file
5
.changeset/fix-fn-5407-backup-checkpoint-truncate.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@runfusion/fusion": patch
|
||||
---
|
||||
|
||||
Fix `fn backup` corrupting the live database. The paired-central-backup feature opened a second `node:sqlite` connection against the live `fusion.db` and ran `PRAGMA wal_checkpoint(TRUNCATE)` before the file copy. A `node:sqlite` SIGSEGV mid-checkpoint (a known recurring crash mode for this codebase) could leave the main DB file extended-but-zeroed. Backups now copy the main DB plus any sibling `-wal`/`-shm` files via plain `cp`; SQLite replays the WAL on first open, so uncheckpointed pages are preserved without us ever opening a second connection against the live database.
|
||||
Reference in New Issue
Block a user