Repository navigation
fix(update): update replaces a still-serving install, then rolls back, when PostgreSQL backup cannot run - #193190
Conversation
…ng install - The pre-migration database backup runs after activation replaces the install. For PostgreSQL families it requires exclusive state ownership and refuses without it, so an update next to a Gateway the updater does not stop swapped the install, failed the backup and rolled back. - Check that ownership in the shared pre-activation step, after the service stop, and refuse with database-engine-preflight while nothing has changed. - The capture and the new check share one ownership probe. - Refs openclaw#193163
|
🦞👀 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 real behavior proof before merge. What this changesThis PR checks PostgreSQL backup ownership before replacing an installation and refuses with retry instructions when ownership is unavailable. Example: A Git installation uses PostgreSQL while its custom LaunchDaemon keeps the Gateway running during openclaw update.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Partial Merge readiness⛔ Blocked before merge - 2 items remain Keep this PR open: it addresses a concrete updater failure with a focused change, and no actionable code defect was found. Priority: P1 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherThe mutable updater prepares Git or package candidates, attempts service stopping, checks publication conditions, replaces installation files, and captures databases before migrations. flowchart TD
A[Update CLI] --> B[Candidate validation]
B --> C[Service stop attempt]
C --> D[PostgreSQL ownership probe]
D --> E[Refusal with retry instructions]
D --> F[Installation activation]
F --> G[Database capture reacquires ownership]
Technical reviewBest possible solution: Keep the shared pre-activation ownership probe and existing backup-time reacquisition without adding a new custody protocol. Do we have a high-confidence way to reproduce the issue? Source establishes activation before transaction capture and capture's PostgreSQL ownership refusal; the exact reported worker exit and shutdown failures remain unverified, and no target code was executed during this review. Is this the best way to solve the issue? The shared capture owner is the smallest appropriate repair: detect an already-known ownership obstruction before publication, preserve the actual capture check, and retain the documented retry path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 57382781c4c0. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +38, Tests -1, Docs +7. Total +44 across 5 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. Review metrics
LabelsLabel changes: No label 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 HistoryReview history (1 earlier review cycle)
Reviewed November 5, 2026, 12:48 AM ET / 05:48 UTC (Revision 2). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…, when PostgreSQL backup cannot run (openclaw#193190) Related: openclaw#193163 Companion: openclaw#193242 ## What Problem This Solves `openclaw update` can replace a serving installation before discovering that PostgreSQL backup cannot acquire exclusive state ownership, for example when a custom service owns the Gateway. ## User Impact The update now refuses with `database-engine-preflight` before activation when PostgreSQL capture cannot acquire ownership. The previous installation remains unchanged and the Gateway keeps serving. The message names the next step: stop the Gateway through its service owner, then rerun `openclaw update`. Stopped-service updates still proceed, and updates with no PostgreSQL family keep their existing behavior. This preserves the update contract: refuse only for the named backup-ownership risk, preserve the previous Gateway on refusal, and provide an actionable retry path. ## Why This Change Was Made The shared pre-activation callback probes the same ownership used by database capture. The actual backup still reacquires and checks ownership after activation; a Gateway starting between the two checks retains the existing backup-time refusal. This change deliberately does not introduce a new custody protocol. This is the narrow PostgreSQL part of openclaw#193163. A separate companion handles the generic Git persisted-owner check; neither change claims to reproduce or fix the reported 0.372-second worker exit or missing-chunk shutdown chain. The installed updater must contain this repair; when upgrading with an older driver, stop the unmanaged Gateway first. The original commits and contributor credit remain with @etzelm. The maintainer follow-up merges main without rewriting that history and consolidates existing capture fixtures. ## Evidence - On main `6df4b062a20`, the six preflight scenarios produce exactly two intended failures: Git and package updates replace the install while PostgreSQL ownership is held. Both stopped-service controls and both SQLite held-ownership controls pass. Vitest 22.99 s; complete command 128.95 s including compilation. - With the fix, 68 focused tests pass across update execution and capture/retention. Complete command 148.48 s; the execution suite checks refusal before mutation, the next-step message, service stopping, and unchanged non-PostgreSQL behavior. The retention suite still exercises both real transaction owners, snapshot cleanup, late-write retention, first-writer diagnostics, and package rollback. - Scoped lint, update-CLI typechecking, formatting, and all baseline/line-cap ratchets pass. The shared test ceiling is unchanged; the allocation is removed. Production +51/-13 = +38 lines for the shared probe and call site; tests +139/-140 = -1 line. - Independent Codex autoreview: scoped-clean through P2 for `6df4b062a20` → `b4fc5cda32dc1228a5a11400b41a4da8b6d8c011`; no accepted/actionable findings. The review inspected supplied source and did not run tests. Limitations: macOS local boundary proof with synthetic I/O, not an end-to-end PostgreSQL deployment or native custom LaunchDaemon. The earlier real serving-process Git proof belongs to the companion scope. No inference model is involved in this maintenance-path proof. ClawSweeper reviewed `b4fc5cda32dc1228a5a11400b41a4da8b6d8c011`: no code findings; its remaining hold requests real CLI/PostgreSQL/latest-stable and stored-data compatibility proof. Those environment/upgrade cells remain unrun; this PR changes no schema or data format. Exact-head [CI](https://github.com/openclaw/openclaw/actions/runs/41975816063) and `openclaw/ci-gate` passed, including all three PostgreSQL conformance shards. This adds Linux conformance coverage, not the unrun custom-service/upgrade scenario. Co-authored-by: Mitchell Etzel <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
…, when PostgreSQL backup cannot run (#193190) Related: #193163 Companion: #193242 ## What Problem This Solves `openclaw update` can replace a serving installation before discovering that PostgreSQL backup cannot acquire exclusive state ownership, for example when a custom service owns the Gateway. ## User Impact The update now refuses with `database-engine-preflight` before activation when PostgreSQL capture cannot acquire ownership. The previous installation remains unchanged and the Gateway keeps serving. The message names the next step: stop the Gateway through its service owner, then rerun `openclaw update`. Stopped-service updates still proceed, and updates with no PostgreSQL family keep their existing behavior. This preserves the update contract: refuse only for the named backup-ownership risk, preserve the previous Gateway on refusal, and provide an actionable retry path. ## Why This Change Was Made The shared pre-activation callback probes the same ownership used by database capture. The actual backup still reacquires and checks ownership after activation; a Gateway starting between the two checks retains the existing backup-time refusal. This change deliberately does not introduce a new custody protocol. This is the narrow PostgreSQL part of #193163. A separate companion handles the generic Git persisted-owner check; neither change claims to reproduce or fix the reported 0.372-second worker exit or missing-chunk shutdown chain. The installed updater must contain this repair; when upgrading with an older driver, stop the unmanaged Gateway first. The original commits and contributor credit remain with @etzelm. The maintainer follow-up merges main without rewriting that history and consolidates existing capture fixtures. ## Evidence - On main `69d6eae050e`, the six preflight scenarios produce exactly two intended failures: Git and package updates replace the install while PostgreSQL ownership is held. Both stopped-service controls and both SQLite held-ownership controls pass. Vitest 22.99 s; complete command 128.95 s including compilation. - With the fix, 68 focused tests pass across update execution and capture/retention. Complete command 148.48 s; the execution suite checks refusal before mutation, the next-step message, service stopping, and unchanged non-PostgreSQL behavior. The retention suite still exercises both real transaction owners, snapshot cleanup, late-write retention, first-writer diagnostics, and package rollback. - Scoped lint, update-CLI typechecking, formatting, and all baseline/line-cap ratchets pass. The shared test ceiling is unchanged; the allocation is removed. Production +51/-13 = +38 lines for the shared probe and call site; tests +139/-140 = -1 line. - Independent Codex autoreview: scoped-clean through P2 for `69d6eae050e` → `b4fc5cda32dc1228a5a11400b41a4da8b6d8c011`; no accepted/actionable findings. The review inspected supplied source and did not run tests. Limitations: macOS local boundary proof with synthetic I/O, not an end-to-end PostgreSQL deployment or native custom LaunchDaemon. The earlier real serving-process Git proof belongs to the companion scope. No inference model is involved in this maintenance-path proof. ClawSweeper reviewed `b4fc5cda32dc1228a5a11400b41a4da8b6d8c011`: no code findings; its remaining hold requests real CLI/PostgreSQL/latest-stable and stored-data compatibility proof. Those environment/upgrade cells remain unrun; this PR changes no schema or data format. Exact-head [CI](https://github.com/openclaw/openclaw/actions/runs/41975816063) and `openclaw/ci-gate` passed, including all three PostgreSQL conformance shards. This adds Linux conformance coverage, not the unrun custom-service/upgrade scenario. Co-authored-by: Mitchell Etzel <[email protected]> Co-authored-by: Peter Steinberger <[email protected]> (cherry picked from commit 1db0343) Stable adaptation: preserve v2026.11.5 capture/boot-write settlement and existing retention fixtures; share only capture ownership acquisition with the pre-activation check. Allocate 69 net regression lines without importing later cohort/rollback features. Co-authored-by: RomneyDa <[email protected]>
Related: #193163
Companion: #193242
What Problem This Solves
openclaw updatecan replace a serving installation before discovering that PostgreSQL backup cannot acquire exclusive state ownership, for example when a custom service owns the Gateway.User Impact
The update now refuses with
database-engine-preflightbefore activation when PostgreSQL capture cannot acquire ownership. The previous installation remains unchanged and the Gateway keeps serving. The message names the next step: stop the Gateway through its service owner, then rerunopenclaw update.Stopped-service updates still proceed, and updates with no PostgreSQL family keep their existing behavior. This preserves the update contract: refuse only for the named backup-ownership risk, preserve the previous Gateway on refusal, and provide an actionable retry path.
Why This Change Was Made
The shared pre-activation callback probes the same ownership used by database capture. The actual backup still reacquires and checks ownership after activation; a Gateway starting between the two checks retains the existing backup-time refusal. This change deliberately does not introduce a new custody protocol.
This is the narrow PostgreSQL part of #193163. A separate companion handles the generic Git persisted-owner check; neither change claims to reproduce or fix the reported 0.372-second worker exit or missing-chunk shutdown chain. The installed updater must contain this repair; when upgrading with an older driver, stop the unmanaged Gateway first.
The original commits and contributor credit remain with @etzelm. The maintainer follow-up merges main without rewriting that history and consolidates existing capture fixtures.
Evidence
69d6eae050e, the six preflight scenarios produce exactly two intended failures: Git and package updates replace the install while PostgreSQL ownership is held. Both stopped-service controls and both SQLite held-ownership controls pass. Vitest 22.99 s; complete command 128.95 s including compilation.69d6eae050e→b4fc5cda32dc1228a5a11400b41a4da8b6d8c011; no accepted/actionable findings. The review inspected supplied source and did not run tests.Limitations: macOS local boundary proof with synthetic I/O, not an end-to-end PostgreSQL deployment or native custom LaunchDaemon. The earlier real serving-process Git proof belongs to the companion scope. No inference model is involved in this maintenance-path proof.
ClawSweeper reviewed
b4fc5cda32dc1228a5a11400b41a4da8b6d8c011: no code findings; its remaining hold requests real CLI/PostgreSQL/latest-stable and stored-data compatibility proof. Those environment/upgrade cells remain unrun; this PR changes no schema or data format.Exact-head CI and
openclaw/ci-gatepassed, including all three PostgreSQL conformance shards. This adds Linux conformance coverage, not the unrun custom-service/upgrade scenario.