Repository navigation
fix(sqlite): prevent snapshot starvation under writes - #113708
Merged
Merged
Conversation
Member
Author
|
Merged via squash.
|
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Jul 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related: #113306
What Problem This Solves
Fixes an issue where SQLite snapshots could make no progress under sustained concurrent WAL writes. Node's stepped online backup restarts when another connection changes the source, so a busy OpenClaw state database could keep the snapshot process scanning the same early pages indefinitely.
Why This Change Was Made
The source connection now opens and activates one explicit read transaction before integrity validation and online backup. Validation and copied bytes therefore come from the same SQLite snapshot, and the transaction is rolled back before the source connection closes.
This follows the existing pinned-read pattern in the read-only SQLite location helper instead of changing backup batch size or adding a retry budget.
User Impact
Snapshot and backup operations remain consistent and complete under active WAL write load instead of starving. Concurrent WAL writers can continue while OpenClaw copies a stable read state, and the published snapshot still receives the existing integrity, index, foreign-key, compaction, and durability checks.
Evidence
BackupJobrepeatedly callssqlite3_backup_step; SQLite documents that external source writes restart the backup.BEGINplusPRAGMA schema_versioncopied the same 5,045-page, 20,664,320-byte source in 18 ms while the writer remained active.src/infra/sqlite-snapshot.test.tsinjects a WAL commit immediately before backup and proves the snapshot contains only the transaction-pinned state.tbx_01kycrts2k0qa02ctx1armvmz1, 30 passed / 2 platform skips.pnpm check:changed:tbx_01kycsj0z236xv1wsrp24s99sq, passed in 4m52s.cbx_fb95c4edd52c, Apple Virtualization, Node 24.15.0): full default profile passed in 51.4s with 25 concurrent restores, 57,312 writer rows, crash recovery, publication/restore/repository interruption, unsafe-index repair, VACUUM interruption, compaction, and post-compaction restore all verified.784f055fe46aa3314615b5d5461425f787170b26e7b2fc7347d434a3252a5cb1.c7g.8xlargeleases, but the broker withdrew SSH before code execution on both; no application result is inferred from those infrastructure failures.