Repository navigation
fix: doctor read-only database inspections time out on large agent databases - #142179
Conversation
|
🦞👀 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: blocked before merge. Reviewed September 8, 2026, 9:43 AM ET / 13:43 UTC. ClawSweeper reviewWhat this changesScales SQLite snapshot deadlines with database size, shares timeout diagnostics with integrity checks, and updates regression coverage and documentation. Merge readiness⛔ Blocked before merge - 1 item remains This remains a useful fix: current main still imposes the snapshot deadline that triggers the reported failure. No blocking correctness findings remain, and the related merged integrity fix does not cover this path. Priority: P2 Review scores
Verification
How this fits togetherDoctor and other database diagnostics inspect private SQLite snapshots. The snapshot worker controls how long copying may run and returns either a prepared snapshot or an actionable error. flowchart TD
A[Doctor and database diagnostics] --> B[Read source file size]
B --> C[Calculate bounded time budget]
C --> D[Private snapshot worker]
D --> E[Snapshot ready]
D --> F[Timeout or cancellation]
E --> G[Inspect database]
F --> H[Join child and clean staging]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +26, Tests +131, Docs +4. Total +161 across 5 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Use one bounded, size-aware inspection budget while preserving private snapshots, cancellation cleanup, and quiet diagnostic output. Do we have a high-confidence way to reproduce the issue? Yes, from source: Doctor's snapshot subprocess is killed after 30 seconds even when copying a valid large database takes longer; no runtime reproduction was executed here. Is this the best way to solve the issue? Yes. Extending the existing integrity-budget policy to snapshot workers repairs the workload mismatch at its owner without changing snapshot selection or stored data. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 865f1bbdbf44. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
Use the same size-derived lifetime budget for asynchronous and synchronous read-only snapshots and the integrity child: 30 seconds plus one second per 32 MiB, rounded up and capped at 30 minutes. Keep one budget resolver, size formatter, info log, and timeout message, with integrity phase details preserved. Failed source stats retain the base budget and child diagnostics. Release-note context: SQLite read-only diagnostics now allow large database snapshots to finish instead of stopping at a fixed 30-second deadline. Timeout errors report the applied budget and source size. This covers Doctor readiness and other existing snapshot callers without changing when snapshots are taken or how databases are read.
The info-level snapshot budget line polluted quiet CLI stdout and stderr contracts pinned by the gateway, health, Doctor, and ACP process tests. Keep routine budget diagnostics at debug level while preserving the size and applied budget in timeout errors. Update the existing logging assertions and documentation. Changed checks and Codex autoreview passed; focused worker and CLI process validation passed 77 tests with one existing platform-dependent skip.
a0a3f0a to
60f4f8f
Compare
|
Merged via squash.
|
* commit '04869ae4899ad0524c3287759798362b0d62fef8': (677 commits) fix(release): pin Kova census refresh (#142104) fix: doctor read-only database inspections time out on large agent databases (#142179) docs: align v2026.9.3 framing with release announcement (#142307) fix(ui): discover models when default-model pickers open (#142105) fix(ci): keep Docker upgrade seed baseline older than target (#142273) refactor(tests): reuse named OAuth credential fixtures (#142272) fix(ci): keep mobile release helpers out of source checks (#142115) chore(ui): refresh control ui locales (#142147) fix(active-memory): explain why recall was skipped (#138658) fix(media): preserve converted images with HEIC filenames (#142263) docs: add v2026.9.3 release notes (#142277) fix(ui): retire picker focus listeners together (#142258) fix(ui): keep menu hover colors consistent across themes (#142243) fix(release): keep changelog credits within verified history (#142261) fix: keep tool-finalizer placeholders private in message-only groups (#138645) perf(tui): carry prepared URL membership through rendering (#142262) test(ui): await activity cache imports before teardown (#142282) fix(qa): align auth and Workshop proofs with runtime contracts (#142280) feat(xai): use one curated catalog and concrete setup default (#142136) refactor(outbound): reuse prepared sendability facts (#142252) ...
…tabases (openclaw#142179) * fix(sqlite): scale the read-only snapshot budget with database size Use the same size-derived lifetime budget for asynchronous and synchronous read-only snapshots and the integrity child: 30 seconds plus one second per 32 MiB, rounded up and capped at 30 minutes. Keep one budget resolver, size formatter, info log, and timeout message, with integrity phase details preserved. Failed source stats retain the base budget and child diagnostics. Release-note context: SQLite read-only diagnostics now allow large database snapshots to finish instead of stopping at a fixed 30-second deadline. Timeout errors report the applied budget and source size. This covers Doctor readiness and other existing snapshot callers without changing when snapshots are taken or how databases are read. * fix(sqlite): keep snapshot budget diagnostics at debug level The info-level snapshot budget line polluted quiet CLI stdout and stderr contracts pinned by the gateway, health, Doctor, and ACP process tests. Keep routine budget diagnostics at debug level while preserving the size and applied budget in timeout errors. Update the existing logging assertions and documentation. Changed checks and Codex autoreview passed; focused worker and CLI process validation passed 77 tests with one existing platform-dependent skip.
Retain unfinished agent inspections under the Gateway lifetime instead of turning a foreground timeout into a fatal startup error. Keep the agent degraded until inspection and guarded credential, session, and model preparation complete; cancel and join that work during shutdown. Preserve caller cancellation, propagate failures until background handoff, and keep inherited auth snapshots within their selected state directory. Thanks to @desksk for the report and offline integrity timings. Refs #150574, #141918, #142179, #150444.
Retain unfinished agent inspections under the Gateway lifetime instead of turning a foreground timeout into a fatal startup error. Keep the agent degraded until inspection and guarded credential, session, and model preparation complete; cancel and join that work during shutdown. Preserve caller cancellation, propagate failures until background handoff, and keep inherited auth snapshots within their selected state directory. Thanks to @desksk for the report and offline integrity timings. Refs #150574, #141918, #142179, #150444.
Retain unfinished agent database inspections under the Gateway lifetime so a slow healthy database no longer turns its foreground wait timeout into a fatal startup error. Keep affected agents degraded until inspection and guarded credential, session, and model preparation complete; healthy agents can serve in the meantime. Corruption and pending migrations retain Doctor guidance. Compose deferred admission with the existing Linux spawn-broker owner. Shutdown cancels and joins retained inspection and preparation before broker cleanup. Preserve caller cancellation, foreground failures before handoff, and inherited auth snapshots within their selected state directory. Thanks to @desksk for the report and offline integrity timings. Validation: recorded focused and real SQLite-child/HTTP boundary proof, scoped-clean Codex review, and green exact-head CI. Published-updater and retained Windows-service compatibility remain unverified; the PR records the scoped Rank-up skip. Closes #150574. Related: #141918, #142179, #150444, #150564.
…150755) Retain unfinished agent database inspections under the Gateway lifetime so a slow healthy database no longer turns its foreground wait timeout into a fatal startup error. Keep affected agents degraded until inspection and guarded credential, session, and model preparation complete; healthy agents can serve in the meantime. Corruption and pending migrations retain Doctor guidance. Compose deferred admission with the existing Linux spawn-broker owner. Shutdown cancels and joins retained inspection and preparation before broker cleanup. Preserve caller cancellation, foreground failures before handoff, and inherited auth snapshots within their selected state directory. Thanks to @desksk for the report and offline integrity timings. Validation: recorded focused and real SQLite-child/HTTP boundary proof, scoped-clean Codex review, and green exact-head CI. Published-updater and retained Windows-service compatibility remain unverified; the PR records the scoped Rank-up skip. Closes openclaw#150574. Related: openclaw#141918, openclaw#142179, openclaw#150444, openclaw#150564.
Related: #141918, #141412.
What Problem This Solves
Fixes an issue where read-only inspections of a large SQLite database, such as the memory-core readiness check in
openclaw doctor, fail with "SQLite read-only snapshot timed out after 30 seconds" whenever the database is too large to copy in 30 seconds. On the team Gateway the 9.4 GB agent database fails this way on every doctor run.Why This Change Was Made
The read-only worker builds a private copy with SQLite's online backup API, so its cost grows with file size, but its child process had the fixed 30-second inspection deadline sized for a 300 MiB synthetic database. #141918 already gave the integrity child a size-derived budget; this change moves that budget into one shared helper and applies it to both read-only worker entry points: 30 seconds for startup and shutdown plus one second per 32 MiB, rounded up and capped at 30 minutes. The timeout error names the applied budget and file size, and budgets above the base are logged. Non-goals: when snapshots are taken is unchanged, and whether tiny metadata reads should use a live read-only connection instead of a full snapshot is a separate owner decision.
User Impact
Doctor and other read-only inspections complete on large installs instead of reporting a spurious timeout; operators see the applied budget when a copy genuinely exceeds it.
Evidence
Team host (2026-09-08):
openclaw doctor --lint --all --jsonon the 9.4 GB agent database failed the memory-core check with the 30-second snapshot timeout; a niced online backup of the same file took 115 seconds niced (about 87 MB/s) on 2026-09-08 at 13:06 UTC, against which the size-derived budget for that file is 331 seconds. Regression tests fail on the pre-fix code for the intended reason and verify the size-derived budget for both the async and sync worker paths and the new error text.node scripts/check-changed.mjspassed; focused snapshot, cancellation, integrity, and read-only worker suites pass. Codex-backed autoreview at P1 before landing.Known Gaps
Each inspection still copies the whole database into the private staging directory; large installs pay that disk and I/O cost per doctor run.