Skip to content

fix: report blocked SQLite WAL checkpoints in status and doctor - #146775

Merged
steipete merged 2 commits into
mainfrom
steipete/upd-wal-checkpoint-starvation
Sep 13, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/upd-wal-checkpoint-starvation

Conversation

@steipete

@steipete steipete commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #146744
Refs #146719

What Problem This Solves

A SQLite reader can prevent a passive WAL checkpoint from finishing while SQLite returns busy=0, causing OpenClaw to report success and leave operators without a useful warning.

User Impact

openclaw status --deep and Doctor explain sustained or oversized blocked shared-state checkpoints, show frame progress and the last completed checkpoint, and name a graceful Gateway restart and status report as the next steps. Checkpoint errors are also recorded and reported.

This addresses the diagnostic gap. The long-lived reader behind the original Windows incident remains unidentified.

Why This Change Was Made

The existing WAL maintenance handle now records each attempt and classifies incomplete frame progress as blocked. A warning appears after two consecutive blocked observations, or after one if the WAL exceeds max(2 × database bytes, 64 MiB); the floor matches the existing retained-WAL size limit. Completion clears the warning.

Status and Doctor consume the same recorded observation through the existing status RPC. Observations last for the open handle's lifetime, reset on retirement/restart, and are absent before the first maintenance attempt or on older Gateways. Normal periodic sampling remains every 30 minutes. Reading the observation does not probe storage or run a checkpoint. The native PRAGMA remains in the existing SQLite owner; file-size observation failures are recorded and logged without changing a completed checkpoint into a failure.

Reported by @thegizmopro (#146719).

Evidence

  • The new real-SQLite passive-checkpoint regression failed before the repair with expected false, received true; status/Doctor regressions also failed when their production changes were reversed.
  • Focused owner and status/Doctor suites passed: 271 tests across 12 files, with 8 existing platform skips. Coverage includes frame counts, release and recovery, size-derived warnings, scheduled checkpoint errors, BigInt/array driver results, live-status projection, and error-detail redaction.
  • A five-minute isolated two-agent Gateway rig on macOS (Node 26.8.2, SQLite 3.53.4) completed 400 session/cron writes. During the deliberately held reader, SQLite returned busy=0, while the owner recorded state=blocked, logFrames=120, checkpointedFrames=0, walBytes=494432, databaseBytes=3575808, consecutiveBlocked=122, and warning=true. The last completion timestamp remained unchanged. Releasing the reader produced state=complete, 120/120 frames, consecutiveBlocked=0, and warning=false on the next owner pass.
  • Built-CLI status --deep and doctor --non-interactive both displayed the warning, frame counts, last completion, and restart/report instructions. A later status --deep cleared it. The rig used synthetic state and an external preload to accelerate the existing maintenance timer to one second; production cadence is unchanged.
  • node scripts/check-changed.mjs, pnpm check:architecture, and pnpm build passed on the final layout. A final 94-second replay against the final built runtime completed 120 writes and again recorded blocked 0/30 frames, then complete 30/30 with the warning cleared.
  • Exact-head CI passed on 5f58141d7071aabb26bd0305885179c78f663801: run 34741924699, 118 successful jobs and 14 skipped jobs, including the Windows tests and runtime-topology architecture check.

ClawSweeper review

Reviewed the completed review for 5f58141d7071aabb26bd0305885179c78f663801. No code or test findings remain. Skipped the data-model compatibility proof checkbox: checkpoint health is held only in the existing maintenance handle's closure, is absent before observation and after retirement, and is optional in status responses. This diff changes no schema, durable record, migration, retention policy, or recovery contract; the review's own evidence confirms that the migration concern is inapplicable. Existing real-SQLite and built-Gateway proof covers blocked observations, recovery, and warning clearance. No code changed during landing review.

Classify incomplete passive checkpoint frame progress and retain the last
maintenance observation on the existing WAL owner. Report sustained or
oversized blocked WALs and checkpoint errors through the status RPC, with
a graceful restart and status-report hint. Completed observations clear
the warning; storage lifecycle and checkpoint scheduling stay unchanged.

Fixes #146744
Reported by @thegizmopro (#146719).
@clawsweeper

clawsweeper Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation commands Command implementations size: L maintainer Maintainer-authored PR labels Sep 13, 2026
@steipete
steipete marked this pull request as ready for review September 13, 2026 05:40
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 13, 2026
@clawsweeper

clawsweeper Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 13, 2026, 2:33 AM ET / 06:33 UTC (Revision 3).

ClawSweeper review

What this changes

The PR detects incomplete SQLite write-ahead log checkpoints and reports sustained blockage or errors through status and Doctor, with recovery guidance.

Merge readiness

⛔ Blocked before merge - 1 item remains

The PR remains useful: current main and the latest release retain the busy-only checkpoint check. No blocking defect was found. The previous migration-proof blocker does not apply because the new observations are process-local and introduce no persisted-format change.

Priority: P2
Reviewed head: 5f58141d7071aabb26bd0305885179c78f663801

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with strong runtime evidence and meaningful regression coverage; no blocking correctness or security finding remains.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): Captured real-SQLite Gateway observations exercise the maintenance owner under a held reader, demonstrate warnings in built status and Doctor, and show completion and warning clearance after release, including a replay against the final built runtime.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): Captured real-SQLite Gateway observations exercise the maintenance owner under a held reader, demonstrate warnings in built status and Doctor, and show completion and warning clearance after release, including a replay against the final built runtime.
Evidence reviewed 9 items Current main still needs the repair: The fetched main implementation checks only the busy column and returns success when it is zero, without comparing checkpointed and logged frames.
Latest release retains the same defect: The supplied latest release, v2026.9.4, also uses the busy-only predicate. This PR's repair is not present in that release.
Checkpoint classification and observation lifetime: The helper compares frame progress, retains the last completed timestamp, applies the documented warning thresholds, and returns a copy of its closure-local observation. File-size failures remain advisory. The existing WAL owner still executes the native checkpoint and retains its scheduling and maintenance exclusion.
Findings None None.
Security None None.

How this fits together

SQLite maintenance checkpoints committed writes from the write-ahead log into OpenClaw’s databases. This change records the existing maintenance results and exposes shared-state warnings through the Gateway’s status RPC to diagnostic commands.

flowchart LR
  A[Gateway state writes] --> B[SQLite database and WAL]
  B --> C[Existing checkpoint maintenance]
  C --> D[Handle-local health observation]
  D --> E[Gateway status RPC]
  E --> F[Status and Doctor warnings]
Loading

Before merge

  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source +213, Tests +321, Docs +29, Other 0. Total +563 across 25 files.

View PR surface stats
Area Files Added Removed Net
Source 12 248 35 +213
Tests 11 362 41 +321
Docs 1 29 0 +29
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 25 640 77 +563

Review metrics

Metric Value Why it matters
Production versus test growth Production net +213 lines; tests and test support net +321 lines Production growth implements handle-local observations and diagnostic propagation; regression coverage exercises classification, recovery, lifecycle, and redaction.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/flows/doctor-core-checks.runtime.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #146744
Summary: This PR is the candidate fix for the independently reproduced checkpoint diagnostic defect; the original Windows incident has broader unresolved context.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Keep checkpoint classification and observations with the existing maintenance owner, with status and Doctor consuming those facts without triggering database work.

Do we have a high-confidence way to reproduce the issue?

Yes: hold a SQLite read transaction, commit another write, and invoke a PASSIVE checkpoint; current main treats busy=0 as success despite incomplete frames. Source and captured runtime observations establish the mechanism; this review did not execute it.

Is this the best way to solve the issue?

Yes: the patch repairs result interpretation at the existing owner and shares one warning formatter across diagnostic consumers, without introducing persistence or forced checkpoints.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 32074f6a75b4.

Labels

Label justifications:

  • P2: This repairs a concrete maintenance diagnostic gap without claiming to resolve the unidentified reader behind the original Windows incident.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): Captured real-SQLite Gateway observations exercise the maintenance owner under a held reader, demonstrate warnings in built status and Doctor, and show completion and warning clearance after release, including a replay against the final built runtime.
  • proof: sufficient: Contributor real behavior proof is sufficient. Captured real-SQLite Gateway observations exercise the maintenance owner under a held reader, demonstrate warnings in built status and Doctor, and show completion and warning clearance after release, including a replay against the final built runtime.

Evidence

What I checked:

  • Current main still needs the repair: The fetched main implementation checks only the busy column and returns success when it is zero, without comparing checkpointed and logged frames. (src/infra/sqlite-wal.ts:373, 32074f6a75b4)
  • Latest release retains the same defect: The supplied latest release, v2026.9.4, also uses the busy-only predicate. This PR's repair is not present in that release. (src/infra/sqlite-wal.ts:627, 3a9d69db306c)
  • Checkpoint classification and observation lifetime: The helper compares frame progress, retains the last completed timestamp, applies the documented warning thresholds, and returns a copy of its closure-local observation. File-size failures remain advisory. The existing WAL owner still executes the native checkpoint and retains its scheduling and maintenance exclusion. (src/infra/sqlite-wal-checkpoint.ts:90, 5f58141d7071)
  • Previous migration concern is inapplicable: The prior completed review requested migration or upgrade compatibility proof but listed no findings. Inspection establishes that health is an in-memory value, disappears with handle retirement, and is optional for older Gateway responses; the introduced diff changes no schema, durable record, migration, retention policy, or stored preference. The storage review checkpoint concerns material persistent contracts. Public docs: docs/reference/database-schemas/storage-changes.md. (docs/reference/database-schemas/storage-changes.md, 5f58141d7071)
  • Status propagation and sensitive-detail boundary: Status reads the cached handle's observation without opening or querying SQLite. The summary removes error text for non-sensitive responses, the existing RPC selects sensitivity from admin scope, and both Doctor paths consume the recorded warning. (src/status/summary.ts:530, 5f58141d7071)
  • Captured real Gateway proof: The complete supplied PR body records an isolated macOS Gateway with two agents and 400 session/cron writes: a held reader yielded busy=0 with 0/120 frames and warning=true, then release yielded 120/120 and warning=false. Built status and Doctor displayed the warning; subsequent status cleared it. A final built-runtime replay recorded 0/30 then 30/30 across 120 writes. The timer was externally accelerated; production cadence was unchanged. These observations were reviewed, not rerun. (5f58141d7071)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-09-13T05:47:18.385Z sha d48647e :: blocked before merge. :: none
  • reviewed 2026-09-13T06:18:18.084Z sha 5f58141 :: blocked before merge. :: none

Keep the checkpoint PRAGMA in the existing SQLite owner and pass its result
to the observation helper. Treat file-size observation failures as advisory:
record and log them without refusing an otherwise completed checkpoint or
ownership handoff.

Refs #146744
@steipete
steipete merged commit 8108a5e into main Sep 13, 2026
199 of 200 checks passed
@steipete
steipete deleted the steipete/upd-wal-checkpoint-starvation branch September 13, 2026 07:21
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 13, 2026
* commit '2acbeee461474b6ba41f5186ae1a4e0e80f4087a': (117 commits)
  fix(ui): import the shared deferred helper in sidebar scope tests (#146862)
  fix(ui): copy chat content from its context menu (#146679)
  perf(memory): defer legacy sidecar writer imports (#146815)
  fix(e2e): accept expected Kitchen Sink worker rejection (#146681)
  fix(ui): distinguish absolute and relative file links (#146572)
  feat(ui): keep file previews in tabs and render HTML (#146672)
  refactor: reuse shared deferred promises in UI tests (#146670)
  fix: gateway stop/restart refuses a healthy gateway when the Windows process snapshot misses (#146387)
  improve(crabbox): keep healthy cloud desktops warm on resume (#146816)
  fix: report blocked SQLite WAL checkpoints in status and doctor (#146775)
  feat: share browser dashboards with agents (#146702)
  fix(doctor): continue repairs after legacy agent directory collisions (#146092)
  feat(agents): retry cyber-refused embedded turns on Daybreak (#145291)
  fix: restore media uploads through protected egress (#144902)
  refactor(qa): share capture filter rendering (#146696)
  fix(cli): keep running stream jobs visible as running (#146793)
  refactor(parallels): share gateway readiness loop (#146694)
  fix(sessions): avoid rewriting already-consumed input on release (#146795)
  fix: preserve scheduled conversation delivery after Doctor (#146794)
  perf(ui): avoid redundant session-row provenance work (#146797)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 14, 2026
…claw#146775)

A passive SQLite checkpoint can return busy=0 while a reader prevents it from copying all WAL frames. Record blocked, complete, and failed outcomes on the existing maintenance handle and expose the recorded observation through status --deep and Doctor.

Warn after two blocked observations or a WAL above max(2 × database bytes, 64 MiB), show frame progress and the last completed checkpoint, and name a graceful Gateway restart and status report as the next steps. Completion clears the warning. Observations are process-local; checkpoint scheduling, schemas, retention, and recovery stay unchanged.

Validated by real-SQLite regression coverage, built-Gateway held-reader/recovery proof, and exact-head CI. This fixes the diagnostic gap; the original incident's long-lived reader remains unidentified.

Fixes openclaw#146744
Refs openclaw#146719
Reported by @thegizmopro (openclaw#146719).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations docs Improvements or additions to documentation maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SQLite passive checkpoints blocked by readers are reported successful

1 participant