Repository navigation
fix(update): keep database restoration available when progress polls during Doctor - #192083
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: needs maintainer review before merge. What this changesPause progress polling and drain parent database handles while an update Doctor child runs. Example: A current-build updater runs post-plugin Doctor while polling progress every 250 ms.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this PR addresses a concrete update recovery failure still present on current main, and the focused patch introduces no identified correctness defect. Priority: P1 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe update CLI observes its durable run ledger through a reusable shared-state reader; the Doctor-child owner coordinates subprocess execution, database handoff, and settlement. flowchart TD
A[Update CLI] --> B[Progress observer]
B --> C[Shared state reader]
A --> D[Doctor child owner]
D --> B
D --> E[Database lifecycle owner]
E --> C
D --> F[Doctor subprocess]
F --> G[SQLite maintenance]
Technical reviewBest possible solution: Keep the existing reusable reader and suspend its observation through the shared Doctor-child lifecycle, as this patch does. Do we have a high-confidence way to reproduce the issue? Source connects the retained live progress reader to the missing pre-Doctor suspension, and the body reports four native reproductions plus a regression failing with SQLite error 5; no target code was run during this review. Is this the best way to solve the issue? This is a focused fix at the existing process owner: it prevents the blocking reader rather than retrying Doctor, preserves prior suspension ownership, and retains post-child schema readmission. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 45c571ed441b. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +35, Tests +40. Total +75 across 3 files. Added test files: 0. View PR surface stats
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 3, 2026, 11:52 AM ET / 16:52 UTC. |
Codex Review SummaryThis 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. |
|
Merged via squash.
|
Keep distinct route, ordering, trigger, publication, custody, and fixture-lifecycle contracts from openclaw#192769, openclaw#192540, openclaw#192250, openclaw#192812, openclaw#191643, openclaw#192584, openclaw#192588, and openclaw#192083. Raise only the scalar by the exact measured inherited deficit; production and test LOC remain unchanged.
…192083) (cherry picked from commit d50ccce) Co-authored-by: RomneyDa <[email protected]>
What Problem This Solves
Fixes: every update driven by a current-main updater loses automatic database restoration and skips post-plugin Doctor maintenance, because the updater's own progress display keeps the shared state database open while the post-plugin Doctor needs exclusive access.
User Impact
User impact: updates keep automatic database restoration available, and the post-plugin Doctor completes its maintenance. Before this change, every second update from a current build (for example a 10.10 build updating to a newer one) printed
Automatic database restoration unavailable: databases changed after snapshot capture; the writer is unknown, left the database snapshots on disk, and loggedDoctor could not complete maintenancefrom the post-plugin Doctor, even though the update reported success.Why This Change Was Made
The CLI progress display polls the update ledger every 250 ms. Each poll borrows the shared-state reader pool, which retains the SQLite connection for reuse. During finalization the display is active again, so the parent process holds an open reader on
state/openclaw.sqlite. The post-plugin Doctor child then takes exclusive native custody for its state migration (PRAGMA locking_mode=EXCLUSIVE; BEGIN EXCLUSIVE). An open reader on another connection makes that fail withdatabase is locked. Update capture records the failed migration as unattributable writes, so restoration is refused for the rest of the update. The parent'sobserveUpdateParentDatabaseWritesalready closes its handles before the child, but the next progress tick reopens a reader about 200 ms later.runUpdateDoctorProcessowns every update Doctor child: the activation Doctor, the fresh pre- and post-plugin Doctors, andrun-mainDoctor results. It now pauses the run's progress observer, waits for any in-flight poll to settle, and closes parent state handles before the child starts. Observation resumes after the child settles and its existing post-child close runs. If another owner had already paused the observer, for example activation, that pause stays in place.Rejected alternatives:
Evidence
src/cli/update-cli/update-command-doctor-child.test.ts, "keeps live progress observation from refusing the Doctor's exclusive state custody". It starts real progress observation, waits until a ledger read has landed, then runs a real child process that takesPRAGMA locking_mode=EXCLUSIVE; BEGIN EXCLUSIVE. Red on base: the child exits 1 withError: database is locked(errcode 5). Green with the fix. The doctor-child,progress.test.tsandprogress.observation.test.tssuites all pass, 37 tests.Automatic database restoration cannot attribute migration writes: SQLite migration publication could not be verified: database is locked. The update then warnedAutomatic database restoration unavailable. An instrumented build traced the blocking handle to the parent's state-read worker, reopened byupdateRuns.getfrom the 250 ms progress poller about 200 ms after the parent closed its handles. Native red/green on the same box, clean packages, 2026.10.9 → build → same build relabelled 2026.10.11 with a live systemd Gateway: base main d615435, second hop:database is lockedx3,Doctor could not complete maintenancex1,Automatic database restoration unavailablex1. Fixed head (main 01838fc + this change), second hop: 0 / 0 / 0; both hops rc=0 and Gateway/readyzready afterwards.oxlintcore shard andtsgo:corepass.$autoreviewis scoped-clean. An independentcodex execreview returned NO FINDINGS.