Repository navigation
fix: let updates proceed while a busy agent database keeps writing - #201327
Conversation
Artifact-preserving SQLite inspection copies the database bytes and compares them until they hold still. A live writer that checkpoints during every copy (a busy Gateway agent turn on a large agent database) exhausts all ten attempts, so update admission refused with "SQLite source did not stabilize (reason=wal-copy-unstable, attempts=10)". When every attempt loses to committed writes on a complete WAL family (main, WAL and index present, no rollback journal), take one SQLite read transaction through the existing online-backup owner instead. Only a live connection can keep checkpointing, so its WAL index is current: the read cannot recover it or change the 96-byte commit header that update captures compare, only reader slots after it. Idle, crashed and index-less families never churn and keep the byte-neutral copy; rollback-journal families keep refusing because a native reader would block their writer. Refs #200791
|
🦞👀 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. |
|
Codex review: needs maintainer review before merge. What this changesThis PR falls back to SQLite online backup when repeated checkpoint activity prevents a consistent private file copy. Example: Update admission inspects a 2 GB WAL database while an agent keeps checkpointing it.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Partial Merge readiness✅ Ready for maintainer review Keep this PR open: it addresses a source-confirmed update failure through the existing snapshot owner, with no definite introduced defect found. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherUpdate admission and database inspection send source database paths to an isolated snapshot worker, which returns a consistent private database image for validation. flowchart TD
A[Update admission or inspection] --> B[Isolated snapshot worker]
B --> C[Artifact preserving copy]
C --> D[Consistent private image]
C --> E[Checkpoint retries exhausted]
E --> F[Complete WAL family check]
F --> G[Existing online backup owner]
G --> D
Technical reviewBest possible solution: Let the existing snapshot owner capture a consistent busy-WAL image while retaining source identity checks and private recovery for incomplete or rollback-journal families. Do we have a high-confidence way to reproduce the issue? The current-main regression and copy/WAL verification code establish checkpoint-driven exhaustion; no target code or tests were executed during this read-only review. Is this the best way to solve the issue? The smallest complete repair belongs in the existing copy owner and reuses its online-backup implementation; the patch does that without adding a competing manager or configuration option. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against aa3eaa2182f3. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +40, Tests +41, Docs +8. Total +89 across 4 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. LabelsLabel changes:
Label justifications:
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 Reviewed November 18, 2026, 11:16 AM ET / 16:16 UTC. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Backport #201327 from main 07baab5, preserving the release's native-CoW and metadata-inspection paths. Backport the cold-storage notification assertion from #197510 (2c4413a): registration and restored transcript notifications are distinct committed changes. Co-authored-by: RomneyDa <[email protected]> Co-authored-by: vincentkoc <[email protected]>
#201327) Artifact-preserving SQLite inspection copies the database bytes and compares them until they hold still. A live writer that checkpoints during every copy (a busy Gateway agent turn on a large agent database) exhausts all ten attempts, so update admission refused with "SQLite source did not stabilize (reason=wal-copy-unstable, attempts=10)". When every attempt loses to committed writes on a complete WAL family (main, WAL and index present, no rollback journal), take one SQLite read transaction through the existing online-backup owner instead. Only a live connection can keep checkpointing, so its WAL index is current: the read cannot recover it or change the 96-byte commit header that update captures compare, only reader slots after it. Idle, crashed and index-less families never churn and keep the byte-neutral copy; rollback-journal families keep refusing because a native reader would block their writer. Refs #200791 (cherry picked from commit 07baab5) Co-authored-by: RomneyDa <[email protected]>
openclaw#201327) Artifact-preserving SQLite inspection copies the database bytes and compares them until they hold still. A live writer that checkpoints during every copy (a busy Gateway agent turn on a large agent database) exhausts all ten attempts, so update admission refused with "SQLite source did not stabilize (reason=wal-copy-unstable, attempts=10)". When every attempt loses to committed writes on a complete WAL family (main, WAL and index present, no rollback journal), take one SQLite read transaction through the existing online-backup owner instead. Only a live connection can keep checkpointing, so its WAL index is current: the read cannot recover it or change the 96-byte commit header that update captures compare, only reader slots after it. Idle, crashed and index-less families never churn and keep the byte-neutral copy; rollback-journal families keep refusing because a native reader would block their writer. Refs openclaw#200791
Related: #200791
What Problem This Solves
Updating while the Gateway is busy writing to a large agent database could be refused before anything changed: "SQLite source did not stabilize (reason=wal-copy-unstable, attempts=10)". Retrying a few minutes later, after the agent turn finished, was the only way through.
User Impact
Update admission and other read-only database inspections no longer give up on a large WAL database that an active writer keeps checkpointing. They take one consistent SQLite read snapshot instead. Idle, crashed, and index-less databases keep the existing byte-for-byte private copy, so nothing changes for them.
Why This Change Was Made
Artifact-preserving inspection copies the database bytes and compares them until they hold still. Appends to the WAL are already tolerated, but a checkpoint during the main-file copy (or the WAL restart after it) invalidates the attempt. With a multi-GB agent database, one copy takes longer than the writer's checkpoint interval, so all ten attempts lose and backoff cannot help.
When every attempt lost to committed writes (
wal-copy-unstable,main-changed-during-copy,wal-changed-during-copy) on a complete WAL family (main file, WAL, and index present, no rollback journal), the copy owner now takes one read transaction through the existing online-backup path. Only a live connection can keep checkpointing, so its WAL index is current: the read cannot recover the index or change the 96-byte commit header that update captures compare, only reader slots after it (the same contract #175774 accepted for verified live owners). Source identity is pinned across the backup. Rollback-journal families still refuse, because a native reader would block their writer.Accepted edge case: if the writer closes in the instant between the last failed copy and the native open, the read-only open sees a closed family. This is visible as a normal refusal or a later capture warning, not data loss.
Rejected alternatives: longer retry backoff (each attempt outlasts the checkpoint interval, so waiting between attempts does not create a quiet window); requiring a recorded owner (agent databases have no owner record, only the shared state database does).
Production LOC: +44/-4 in
src/infra/sqlite-readonly-location.ts. Tests +43/-4, docs +12/-2.Evidence
takes one read transaction when a live WAL writer outlasts every raw copyfails on base with the exact reported error and passes with the fix.keeps a WAL family without its index byte-neutral when every raw copy changespasses on both and pins that the source is unchanged and no-shmis created.wal-copy-unstable, 24 s); online backup succeeded in 3.4 s. With checkpoints disabled the raw copy succeeds, which confirms checkpoints, not appends, are the cause.sqlite-readonly-location*,openclaw-database-preflight, andupdate-command-admitsuites pass (215 tests).pnpm tsgo:coreis clean. Autoreview (P2) is scoped-clean.7eb33ccb25f, update 2026.11.30 → 2026.11.31: the update was refused at candidate admission withSQLite source did not stabilize (reason=wal-copy-unstable, attempts=10)(exit 1).updated to 2026.11.32, exit 0). I confirmed the installed dist contains the change.