Repository navigation
fix: Git checkout updates across a schema change no longer end as post-update-failed after the new release starts - #201600
Conversation
The installed updater kept its shared-state worker owner open across the Gateway restart into the updated build. When that build's boot upgrade replaced state/openclaw.sqlite by copy and swap, every later state open in the updater was refused and a successful update ended as post-update-failed. Release the updater's handles for the restart and its verification, then reopen by path for the remaining steps.
|
🦞👀 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 changesThe PR releases the updater’s shared-state database handles around Gateway restart so post-update work can reopen the replacement database. Example: A Git release update upgrades an agent database from schema 42 to 43 and replaces state/openclaw.sqlite during Gateway startup.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR addresses a documented update lifecycle failure that remains on main; source review found no definite introduced defect. Priority: P1 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe CLI update finalizer restarts and verifies the Gateway, then performs plugin convergence and records completion through the shared-state database owners. flowchart TD
A[CLI update finalizer] --> B[Suspend progress and close handles]
B --> C[Restart and verify Gateway]
C --> D[Boot upgrade replaces database]
C --> E[Retire handles and revoke admissions]
E --> F[Resume progress and post-update work]
F --> G[Record outcome in current database]
Technical reviewBest possible solution: Use the existing progress and database lifecycle owners to release stale handles across restart while preserving pathname refusal and normal completion or failure recording. Do we have a high-confidence way to reproduce the issue? The retained-owner failure is supported by current source and the preceding merged PR’s real busy and idle upgrade results; this read-only review ran no target code. Is this the best way to solve the issue? The patch repairs handle lifetime at the restart boundary using existing owners, retains identity checks, and adds distinct success, failure, and stale-owner controls without speculative machinery. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 1039d5600133. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +54, Tests +178, Docs +11. Total +243 across 7 files. Added test files: 2. 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:
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 Reviewed November 18, 2026, 11:06 PM ET / November 19, 2026, 04:06 UTC. |
…f cases A new database-worker test file pushed the compact CI node plan over its job budget. The restart cases now live with the Doctor child cases, which cover the same close, revoke and progress suspension around another process taking the shared state database.
…ate-after-git-release-restart
With --no-restart nothing replaces the state file during the update, so keep the open handles and their admission. Limit the docs' rerun advice to updaters whose target is already serving.
…ate-after-git-release-restart
|
Merged via squash.
|
…t-update-failed after the new release starts (#201600) * fix(update): reopen shared state after the restart replaces it The installed updater kept its shared-state worker owner open across the Gateway restart into the updated build. When that build's boot upgrade replaced state/openclaw.sqlite by copy and swap, every later state open in the updater was refused and a successful update ended as post-update-failed. Release the updater's handles for the restart and its verification, then reopen by path for the remaining steps. * test(update): keep the restart handoff cases beside the Doctor handoff cases A new database-worker test file pushed the compact CI node plan over its job budget. The restart cases now live with the Doctor child cases, which cover the same close, revoke and progress suspension around another process taking the shared state database. * fix(update): hand off shared state only when the Gateway restarts With --no-restart nothing replaces the state file during the update, so keep the open handles and their admission. Limit the docs' rerun advice to updaters whose target is already serving. (cherry picked from commit f5e7641) Co-authored-by: RomneyDa <[email protected]>
…t-update-failed after the new release starts (openclaw#201600) * fix(update): reopen shared state after the restart replaces it The installed updater kept its shared-state worker owner open across the Gateway restart into the updated build. When that build's boot upgrade replaced state/openclaw.sqlite by copy and swap, every later state open in the updater was refused and a successful update ended as post-update-failed. Release the updater's handles for the restart and its verification, then reopen by path for the remaining steps. * test(update): keep the restart handoff cases beside the Doctor handoff cases A new database-worker test file pushed the compact CI node plan over its job budget. The restart cases now live with the Doctor child cases, which cover the same close, revoke and progress suspension around another process taking the shared state database. * fix(update): hand off shared state only when the Gateway restarts With --no-restart nothing replaces the state file during the update, so keep the open handles and their admission. Limit the docs' rerun advice to updaters whose target is already serving.
…t-update-failed after the new release starts (openclaw#201600) * fix(update): reopen shared state after the restart replaces it The installed updater kept its shared-state worker owner open across the Gateway restart into the updated build. When that build's boot upgrade replaced state/openclaw.sqlite by copy and swap, every later state open in the updater was refused and a successful update ended as post-update-failed. Release the updater's handles for the restart and its verification, then reopen by path for the remaining steps. * test(update): keep the restart handoff cases beside the Doctor handoff cases A new database-worker test file pushed the compact CI node plan over its job budget. The restart cases now live with the Doctor child cases, which cover the same close, revoke and progress suspension around another process taking the shared state database. * fix(update): hand off shared state only when the Gateway restarts With --no-restart nothing replaces the state file during the update, so keep the open handles and their admission. Limit the docs' rerun advice to updaters whose target is already serving. (cherry picked from commit f5e7641) Release adaptation: Production hunk applies unchanged and preserves no-restart bypass. Source regression imported a future boot-upgrade owner absent on baseline. Fixture now performs the existing cache-regression physical rename pattern, preserving the previous SQLite family, rather than importing that new owner. Caller 19/19; native restart proof recorded in final-proof.json. Co-authored-by: RomneyDa <[email protected]>
…t-update-failed after the new release starts (#201600) Baseline adaptation: use the installed driver presentation and path-scoped state lifecycle to close state only across an authorized restart. Renew pathname admission on both outcomes before resuming progress and terminal settlement; preserve existing no-restart and recovery decisions. (cherry picked from commit f5e7641) Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit 9c568a35f7b4b67b0126aa25773322ef88913d76)
…aw#194058) Failed-update triage now captures the operator's environment before managed candidate admission, so a coding agent installed only on the operator's PATH is still offered when the Gateway service's PATH differs. Restores the operator-environment contract from openclaw#134490 and keeps the launch confirmation from openclaw#143139. Proof: shipped CLI on isolated Linux (Crabbox) with a running systemd Gateway: accept launches the operator-only agent, decline starts nothing, base 18bee8e reports no agent found; published 2026.11.1 upgrades to the fix with settings intact. Co-authored-by: TorstenW <[email protected]> Co-authored-by: Peter Steinberger <[email protected]> Co-authored-by: steipete <[email protected]> (cherry picked from commit 7c702c3) Release adaptation: Capture invoking operator env before candidate admission, forward to interactive triage only; preserve latest target selectors, confirmation and lease cleanup ordering. Exact three authorized production paths plus real lifecycle regression. Follow-up dispositions: ad4863d fix: preserve the running installation when an agent updates its Gateway (openclaw#201570); dc73ec0 fix: let updates finish when another tool briefly reads OpenClaw's databases (openclaw#202541); d07b530 fix: clarify PostgreSQL schema upgrades for Git installs (openclaw#202098); e60ea9f test(update): add a Git release upgrade-survivor scenario (openclaw#201956); 2ef6f7b fix(update): build and serve Git releases outside node_modules (openclaw#201917); dbc1aa0 fix: keep the openclaw command and Gateway working after updating a pnpm install (openclaw#201735); f5e7641 fix: Git checkout updates across a schema change no longer end as post-update-failed after the new release starts (openclaw#201600); 2183caf fix: Git checkout updates no longer fail before the new release starts on a schema change or a busy database (openclaw#201463); 47e8649 fix: explain why Doctor cannot restore a scheduled job’s account (openclaw#201550); 8f2cfd4 fix: remove updater-only restrictions from agent maintenance guidance; cb5cfb2 fix: keep a doubtful killed-update recovery on the repair path (openclaw#201361); 24cb734 fix: keep carried-over scheduled jobs running after updates (openclaw#200653); d1276e1 feat(doctor): check OpenClaw ID member roles and honor an optional roles default (openclaw#197785); 0a39956 fix: finish updates when another tool reads OpenClaw's databases during the update (openclaw#201330); ea1c9d5 fix(update): settle remounted package publications before admission (openclaw#201336); 66b5212 fix(update): isolate malformed retained-install markers (openclaw#201199); 7e79c83 fix: let the next update finish a killed source checkout update (openclaw#201009); d905d8a fix: let the next update finish a killed update after the machine restarted (openclaw#200994); fdf0c95 fix: let the next update finish a killed update that had already installed the new version (openclaw#200866); 0c19bcd chore(release): close out 2026.11.5 on main (openclaw#200577); a1940e0 fix(matrix): keep explicit recovery available during deferred migration (openclaw#200805); 18b4776 improve: explain package baseline drift during updates (openclaw#200802); 1ad4cad fix(doctor): reclaim macOS updater runtimes blocked by non-updater processes (openclaw#200732); 427c857 fix: keep one missing archived transcript from blocking every update (openclaw#200733); 802e3f7 fix(update): keep valid cold archives from blocking updates (openclaw#200659); 23fca1a fix: let the next update continue after a killed update when nothing is left to repair (openclaw#200680); 3afe212 fix: let Doctor publish unchanged plugin migrations in any order (openclaw#200658); f65e4db fix(doctor): reclaim runtimes blocked by unrelated Linux processes (openclaw#200657); dab086c fix(update): let candidate Doctor read plugin dependencies from the staged package (openclaw#200595); 3447bee fix(update): keep updates going when the predecessor writes during its stop (openclaw#200569); 0ce9c77 fix: let the next update settle a package publication that a killed update left behind (openclaw#200550); ae31ea3 fix(update): repair handoffs in the journal-pinned lease store (openclaw#200532); 74020ea fix: continue updates when initial SQLite capture is stale (openclaw#200328); 6747b1e feat(update): run Git checkout installs from releases behind the release link (openclaw#199706); e3f8a67 fix(state): keep completed retained agent stores out of startup upgrade (openclaw#200284); 3c512c5 fix(gateway): move managed update lease operations off the main thread (openclaw#200169); ea69fcb chore(release): close out 2026.11.4 on main (openclaw#199956); 618bf31 fix(state): bound startup upgrade copies and pruning to owned state (openclaw#199929); e4a3093 perf(update): replace the candidate canary with a runtime contract check (openclaw#198268); 5dbf569 fix(update): plugin failures never fail an update or Gateway health; 764761e fix(update): refuse missing host prerequisites in one line and record a cause per attempt; 4c4fef4 fix(ui): update dialog claims installation before progress is confirmed (openclaw#199254); 136e1f6 fix(update): retrying an update from a dev checkout is refused after a killed update (openclaw#198673); 3bd03da fix(update): avoid duplicate database copies while the Gateway is stopped (openclaw#198148); 68a839b fix: isolate held agent databases until explicit restoration (openclaw#198180); e333f7e chore(ci): drop retired test-lines allocation records (3/3) (openclaw#197657); fd6fa47 fix: converge Gateway updates with environment-only service overrides (openclaw#196371); 7cf5e75 fix: clarify split-install updates and blocked Doctor repairs (openclaw#196342); 6ff8c86 fix(update): retain lazy sqlite catalog generation (openclaw#197095); 930e1f7 fix: keep stable updates and recovery free of premature migrations (openclaw#196474); a15f737 fix: preserve external plugin data during update rehearsal (openclaw#196301); 92798ae fix: updates survive interrupted heartbeat runs (openclaw#195656); c1e55e2 fix(update): restore LaunchAgent registration after repair contention (openclaw#195406); 715c610 fix(doctor): repair retained ISO session end timestamps (openclaw#194685); 689cfc8 fix(update): reclaim dead closing triage repair leases (openclaw#194503); 86bc89e fix(doctor): keep standing Codex parameter advice out of retirement blockers (openclaw#193650); 691bc8d fix(backup): read the backup engine without copying the live database (openclaw#194234); 000542f fix(backup): backups and updates fail on slow storage when a header probe batch misses its deadline (openclaw#194239); 31a65d5 fix(update): skip --no-lazy-fetch on Git versions without it (openclaw#194198); e45e99d fix(update): preserve dev update sources in tag-only Git clones (openclaw#193109) Validation: Baseline2 intended operator-agent failures/32 controls passed; candidate34/34passed (194058-green.log). Accept launches synthetic operator-only CLI with expected env, decline starts nothing. Isolated updater flow, not live systemd/upgrade qualification. Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit 6689fd575ada8fe40a9593784deac18ec73041cd) (cherry picked from commit 92e7a9fa223b0dc35801f25f70be90b472d9a6b7)
…s on a schema change or a busy database (#201463) * fix(update): report an inconclusive schema read as data at risk only after a candidate opened state * fix(update): keep a shipped updater's hold unless the reread confirms the baseline * test(update): assert the recovered verdict carries no data-at-risk mark * fix(update): keep recorded risk and the in-place Git runner on the conservative inspection route * fix(update): fall back only to a release of the serving build before a recovered restart * test(update): finalize an unmatched in-place checkout hold unchanged * test(update): share the release build fixture and record the test-line allocation * refactor(update): narrow to the installed updater's Git release inspection (cherry picked from commit 2183caf) Release adaptation: Keep only the package update warning when neither Doctor nor the no-restart check could open state. Unknown evidence, recorded risk and changed-schema paths retain conservative behavior. Do not import the Git release switch. Companion audit: PR #201463 is the source. #201668 handles revalidation of recorded risk, not needed for this warning; #201600 and later Git release activation follow-ups are out of scope. Deferred Doctor selector retention is independently ordered at row 17. Co-authored-by: RomneyDa <[email protected]>
What Problem This Solves
On a Git checkout install that uses the release layout, an update that changes a database schema succeeds and then reports failure. The new release starts, migrates state and serves, but
openclaw updateexits 1 withpost-update-failed("SQLite database pathname changed while its worker owner is active; close the existing store first") and says "Your Gateway is still serving 2026.11.5; nothing to restore". Plugin convergence, the post-plugin Doctor, deferred inspections and owed-step settlement for that update never run, and run history records the update as failed.User Impact
User impact: an update across a schema change on a Git release install now finishes with exit 0 and a
succeededrun record, and its post-update steps run in the same update.Why This Change Was Made
Root cause: the updater opens the shared state database through its shared-state worker owner early in the run, and that owner keeps the file open for up to 30 minutes of idle time. When the Gateway restarts into the new release, the new release's boot upgrade replaces
state/openclaw.sqliteby copy and swap and keeps the old file asopenclaw.sqlite.pre-<buildId>. The updater's owner still pins the old file under the same pathname, so the SQLite broker refuses the first new open after the restart. That refusal is correct: two owners in one process must not address one pathname with different files.The fix keeps that check and stops holding the file across the restart. Around the Gateway restart and its verification, the updater now suspends its progress reader and closes its shared-state handles. When the restart settles, it closes anything opened meanwhile, revokes the path admissions and resumes progress. The remaining steps then reopen the current file by path. This is the same close, revoke and suspend sequence the update Doctor child already uses around its exclusive custody (
runUpdateDoctorProcess). The wrapper sits at the caller ofmaybeRestartServiceinupdate-command-post-update.tsand applies only when the Gateway actually restarts. It covers the Git release successor wait, the service refresh restart that the observed run used, and the restart after plugin convergence.Run history: rows written before the restart are committed before the successor starts, and the boot upgrade copies them into the new file (
update_runsis not an ephemeral table in the swap map), so the run is neither lost nor duplicated. The new end-to-end run shows the pre-restart steps in the new file and the run finishingsucceeded. One window remains outside this change: a one-shot ledger write that lands after the successor's copy and before its swap stays only in the.pre-file. The boot upgrade owner is moving to in-place migration on a separate branch, which removes that window in the common case. This change is correct with and without that change, because the copy-and-swap fallback can still happen.Other paths:
--no-restart: the updater does not restart the Gateway, and the swap happens at a later start after the updater has exited. Not affected. The wrapper is skipped, so the updater keeps its open handles and their admission.finishUpdatepath, so it is covered by the same wrapper.Update behavior for published updaters
The fix runs in the installed updater, so it takes effect for updates run by an updater that contains it. An installed updater that has #201463 but not this change still reports
post-update-failedafter a schema-changing Git release update, even though the new release is serving and nothing needs restoring. Recovery needs no action from a person: the next plainopenclaw updatereportsalready-currentand converges plugins. That was observed end to end. Updaters without #201463 fail earlier, before the new release starts, as #201463 describes. No config key, stored field, schema, protocol, dependency, retention or permission changes.Steps left to a person
None. The previous failure mode on old updaters heals on the next plain
openclaw update. If that run cannot happen, the update failure output already names the agent-assisted route (openclaw triage --run --update-result ...).Evidence
End to end through the shipped entry point on macOS, on an isolated launchd Git checkout install with its own profile, state directory and port. The config is synthetic, with no channels, providers or credentials. The setup includes a 512 MiB agent database at schema 42 and, in the busy cell, a separate process writing it at 8 MiB/s. The installed updater is
6691acae(the commit before the 42 → 43 agent schema bump, already on the Git release layout) plus #201463's fix, with or without this change. The target is this PR's head pinned as the dev target. Each cell runs a realopenclaw update --channel dev --yes.openclaw update6691acae+ #201463b220df61(this branch, before the--no-restartrefinement)post-update-failed: "SQLite database pathname changed while its worker owner is active" right after "Gateway: restarted and verified"failed/post-update-failedin the newopenclaw.sqlite; new release serving, agent schema 43, trial settledalready-current, "No plugin updates needed"skipped6691acae+ #201463 + this PR86cfb019(this head)succeeded, 40 steps, none failed, nothing owedalready-currentskipped6691acae+ #201463 + this PR86cfb019(this head)succeeded, 43 steps, none failed, nothing owedEarlier GREEN runs of the same fix, without the
--no-restartrefinement, gave the same outcome. Busy against63b6bbb6: exit 0, 567 s, 45.9 s downtime. Busy against433f59bf: exit 0, 507 s, 50.1 s downtime, thenalready-currentin 173 s. Idle against433f59bf: exit 0, 483 s, 49.5 s downtime. Every run endedsucceededwith no failed step and nothing owed.In every GREEN cell, the Gateway serves the target build from the launcher, the agent database is at schema 43,
.trialis settled, andstate/keepsopenclaw.sqlite.pre-<buildId>beside the newopenclaw.sqlite. The updater no longer prints "Update progress history unavailable" during the restart. The busy cells also print the existingNO ORIGINAL-STATE SNAPSHOTcapture warning. It comes from the 8 MiB/s writer and is unrelated to this change.Extra disk per update, the same with and without this change: one new release tree (4.2 GiB; the previous release is kept for rollback), the agent database's previous generation (about 555 MiB for the 512 MiB fixture), and the shared state's previous generation (about 3.4 MiB). This change adds no files.
Root cause observation (RED, diagnostic build)
A diagnostic build logged the broker's actors at the refusal. The only holder was actor 1, the updater's first shared-state worker store (
dist/state/openclaw-state.worker.js), with keyfile:…:1772574836and references 1, still pinningstate/openclaw.sqlite. The refused admission was the same path with the new file's keyfile:…:1773556963. After the RED run, the newopenclaw.sqliteheld the run asfailed / post-update-failed.openclaw.sqlite.pre-<buildId>held the same run up to the pre-restart steps.Focused tests (in
src/cli/update-cli/update-command-doctor-child.test.ts, beside the Doctor handoff cases) use a child process that replaces the live file with the boot upgrade's ownapplyPlanandcompanionRemovals:succeededwith its pre-swap steps carried over, and the.pre-file never receives the later steps. Red on the base behavior:Command cleanup could not confirm that owned work stopped←Existing-state database generation changed.Also run:
test/scripts/update-restart-module-outcome.test.ts(its vm fixture stubs the new wrapper as a pass-through),test/scripts/eager-import-closure.test.ts,update-command-post-update.test.ts,update-cli.git-service.test.ts,update-command-verification.test.ts,pnpm tsgo:core,pnpm tsgo:core:test, oxlint on touched files,pnpm check:baseline-ratchets,pnpm check:docsandgit diff --check.Review: an independent read-only reviewer assessed the diff and the tests. Its blocker was that verification writes would still go through a pinned owner. That does not hold: verification writes are one-shot ledger transactions that open the current file and check its inode inside the transaction (
update-run-write.tsmutateRun→runExistingOpenClawStateWriteTransaction). The RED run shows verification completing while the old owner was pinned; the refusal comes at the first worker-owner open after verification. Its other points were addressed: a failure-path test was added, the unused child message was removed and the fork argument was commented. A ClawSweeper review raised two P3 findings, both fixed: the handoff is skipped when the Gateway does not restart, and the docs limit the rerun advice to updaters whose target is already serving. It also called the negative control redundant with broker coverage. The control is kept: it is the only test of the update ledger's worker write refusing after a real replacement (Existing-state database generation changed.), a different refusal from the broker's pathname check.autoreviewdoes not run on this machine.Recordings
These are raw asciinema terminal recordings of the real
openclaw updatecells, rendered to MP4 with idle time capped at 2 s. The terminal output is sanitized (home directory shown as~, no usernames or hostnames). Full raw logs are not attached because the Crabbox artifact store rejected the upload from this machine (http 401).RED busy, without this change (exit 1,
post-update-failed):pr201600-red.mp4
RED follow-up, next plain
openclaw updatefrom a RED state (already-current):pr201600-red-next-update.mp4
GREEN busy, this head (exit 0, run
succeeded):pr201600-final-green-busy.mp4
GREEN follow-up, second plain
openclaw update(already-current):pr201600-final-green-second.mp4
GREEN idle, this head (exit 0, run
succeeded):pr201600-final-green-idle.mp4
Decisive RED excerpt
Decisive GREEN excerpt
Not proven
An upgrade that starts from the stable
v2026.11.5release. No published release includes the Git release layout yet, so no release can produce this state; the installed updater in every cell is6691acaefrom main, the last commit before the 42 → 43 agent schema bump.Package installs, the legacy in-place Git runner and the managed-service handoff were checked by code, not end to end (see Other paths).
Linux and Windows hosts. The end-to-end cells ran on macOS launchd only. The code path has no platform branch.
A release trial that backs out to the previous build. The wrapper releases and revokes the state handles whenever the restart settles, success or failure, so later writes open whatever file the path names; only a failed restart after a swap is tested (
reopens the current file when the restart fails), not a back-out end to end.A boot upgrade slow enough that a one-shot ledger write lands between its copy and its swap. That window belongs to the boot upgrade owner (see above).