Repository navigation
fix(update): updates fail when another connection opens the state database during a generation read - #193134
Conversation
…n reads A database generation read failed with "SQLite WAL commit publication could not be verified" whenever another connection opened or closed the database during the read without writing. A native open creates a zero-commit WAL index and the last close removes it; neither publishes a commit, and the empty-WAL rule beside it already treats that churn as unchanged content. Accept only that presence transition: no journal, no WAL frames, and a header whose change counter and commit checksum are still zero. Header changes, committed writers' indexes and real commits still refuse. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Codex review: needs maintainer review before merge. What this changesThis PR allows verified SQLite generation reads to tolerate a WAL index appearing or disappearing without a committed write. Example: Another connection opens state/openclaw.sqlite during a generation read without writing.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: current main still rejects harmless WAL-index transitions, and the focused repair introduces no identified correctness defect. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherUpdate backup and Doctor use the generation owner to turn SQLite file-family observations into fingerprints used for migration admission and automatic restoration checks. flowchart TD
A[Update backup and Doctor] --> B[Database generation owner]
B --> C[SQLite database and sidecars]
B --> D[Private snapshot validation]
C --> E[Content and publication checks]
D --> E
E --> F[Generation fingerprints]
F --> G[Migration and restoration checks]
Technical reviewBest possible solution: Keep the narrow comparison in the existing generation owner while preserving exact fingerprints, receipt fallback, and rejection of real writes. Do we have a high-confidence way to reproduce the issue? Current main explicitly rejects header presence transitions despite unchanged database-family content, and the supplied real-SQLite regressions target that path with reported baseline failures; this read-only review ran no target code. Is this the best way to solve the issue? The shared comparison is the smallest complete repair for transitions during one observation, preserving file verification and existing downstream owners without adding persistent state or configuration. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 29aa438e6502. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +20, Tests +90, Other +5. Total +115 across 3 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReviewed November 5, 2026, 12:25 PM ET / 17:25 UTC (Revision 3). |
…es mid-read A generation read refused when the last connection closed during the read and removed a WAL index that carried commit evidence, although the database and WAL were verified unchanged and a read a moment later succeeds. Without journal data or WAL frames, accept the index disappearing and bind the closed state. A header that changes, or appears with commit evidence, still refuses. Tests assert the exact generation per case, add an appearing committed header guard, and reuse the mid-read hook for the inline spies.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash auto-merge.
|
…abase during a generation read (openclaw#193134) * fix(update): accept a reader's zero-commit WAL index during generation reads A database generation read failed with "SQLite WAL commit publication could not be verified" whenever another connection opened or closed the database during the read without writing. A native open creates a zero-commit WAL index and the last close removes it; neither publishes a commit, and the empty-WAL rule beside it already treats that churn as unchanged content. Accept only that presence transition: no journal, no WAL frames, and a header whose change counter and commit checksum are still zero. Header changes, committed writers' indexes and real commits still refuse. * test(update): allocate test lines for WAL reader index coverage * fix(update): accept a retired WAL index when the last connection closes mid-read A generation read refused when the last connection closed during the read and removed a WAL index that carried commit evidence, although the database and WAL were verified unchanged and a read a moment later succeeds. Without journal data or WAL frames, accept the index disappearing and bind the closed state. A header that changes, or appears with commit evidence, still refuses. Tests assert the exact generation per case, add an appearing committed header guard, and reuse the mid-read hook for the inline spies. * test: set the WAL reader index test-line allocation to its net 90 lines
…abase during a generation read (openclaw#193134) * fix(update): accept a reader's zero-commit WAL index during generation reads A database generation read failed with "SQLite WAL commit publication could not be verified" whenever another connection opened or closed the database during the read without writing. A native open creates a zero-commit WAL index and the last close removes it; neither publishes a commit, and the empty-WAL rule beside it already treats that churn as unchanged content. Accept only that presence transition: no journal, no WAL frames, and a header whose change counter and commit checksum are still zero. Header changes, committed writers' indexes and real commits still refuse. * test(update): allocate test lines for WAL reader index coverage * fix(update): accept a retired WAL index when the last connection closes mid-read A generation read refused when the last connection closed during the read and removed a WAL index that carried commit evidence, although the database and WAL were verified unchanged and a read a moment later succeeds. Without journal data or WAL frames, accept the index disappearing and bind the closed state. A header that changes, or appears with commit evidence, still refuses. Tests assert the exact generation per case, add an appearing committed header guard, and reuse the mid-read hook for the inline spies. * test: set the WAL reader index test-line allocation to its net 90 lines
…abase during a generation read (#193134) * fix(update): accept a reader's zero-commit WAL index during generation reads A database generation read failed with "SQLite WAL commit publication could not be verified" whenever another connection opened or closed the database during the read without writing. A native open creates a zero-commit WAL index and the last close removes it; neither publishes a commit, and the empty-WAL rule beside it already treats that churn as unchanged content. Accept only that presence transition: no journal, no WAL frames, and a header whose change counter and commit checksum are still zero. Header changes, committed writers' indexes and real commits still refuse. * test(update): allocate test lines for WAL reader index coverage * fix(update): accept a retired WAL index when the last connection closes mid-read A generation read refused when the last connection closed during the read and removed a WAL index that carried commit evidence, although the database and WAL were verified unchanged and a read a moment later succeeds. Without journal data or WAL frames, accept the index disappearing and bind the closed state. A header that changes, or appears with commit evidence, still refuses. Tests assert the exact generation per case, add an appearing committed header guard, and reuse the mid-read hook for the inline spies. * test: set the WAL reader index test-line allocation to its net 90 lines (cherry picked from commit 50cfa7d) Co-authored-by: RomneyDa <[email protected]>
What Problem This Solves
Fixes: updates fail with "SQLite WAL commit publication could not be verified" when anything opens or closes the state database during a generation read, even without writing.
User Impact
User impact: an update no longer fails, or loses automatic database restoration, just because another connection opened or closed the state database during a generation read without committing. Real writes during the read still fail the same way they do now.
Why This Change Was Made
readUpdateDatabaseGenerationandreadUnchangedUpdateDatabaseGenerationcompare the WAL index header (-shm) before and after reading, and refused when it appeared or disappeared. Neither event publishes a commit. A connection that opens a closed WAL database creates an index whose change counter and commit checksum are zero. When the last connection closes, SQLite checkpoints and removes the index, including one that recorded earlier commits.With no rollback journal and no WAL frames, the read now accepts the index disappearing, and accepts a new index that carries no commit. The database, journal and WAL are already verified byte-for-byte across the read, so neither case can hide a commit. The result is bound to the state after the read, which is exactly what a read a moment later returns. A header that changes and stays, or appears with commit evidence, still refuses. So does any real commit, which fails earlier with "SQLite file generation changed while reading". Fingerprints,
emptyReaderAlternateand receipt formats are unchanged. A receipt is not reused across the transition, and the caller reads again.Evidence
On one Mac, four updates hit this error on
state/openclaw.sqlite(Oct 26 twice, Nov 2, Nov 4). On Nov 4 the Gateway had already stopped. The pre-migration backup first lost its write generation ("Database changed during capture"). Then the parent's ledger observation before Doctor failed after 2.2 seconds, and the run endedpost-update-failedeven though the new Gateway verified healthy.Real SQLite probes against an unchanged 615 MB WAL database, with a separate process acting during the read, showed the same error when a connection opened or closed mid-read without writing. A real commit mid-read gave "SQLite file generation changed while reading".
The tests in
src/infra/update-database-generations.test.tsopen or close a realnode:sqliteconnection at the final stable read and assert the exact generation each case publishes, plus that a second read in the same state agrees. The open, close and receipt cases failed on basea1f99240c836. The last-writer case (a writer commits, checkpoints with TRUNCATE, then closes during the read) failed on the previous head4c5428efwith this error and passes now with the closed database's generation. A commit during the read still refuses, and so does an index that appears with a nonzero change counter. I mutated the new check to accept any new index and that guard failed, so it does catch overreach.The whole file passes (47 tests) on
e342625e; head3a112f07only adds a merge of main's Doctor config change. Before the merges of main, which touched UI, media, process supervisor and Doctor config code, nine generation consumer test files in the infra project passed (243 tests), plusupdate-command-migrated-schema(21). Format and oxlint pass on the touched files, and the test-line check passes with this PR's allocation set to its net 90 added lines.tsrson core and on the infra test project shows only the existingpackages/aierror that main also has. An independent autoreview (Codex, P0 to P2) found nothing to fix.This PR doesn't identify which process opened the database on that machine. The read now tolerates any opener or closer that doesn't commit. The stuck-run repair from that failure is #193132. Two follow-ups cover the rest of the Nov 4 run. #193622 keeps the update going when the parent ledger read fails anyway. #193626 stops the backup reporting "Database changed during capture" when a reader opens between its two reads.