Skip to content

fix(update): update replaces a still-serving install, then rolls back, when PostgreSQL backup cannot run - #193190

Merged
steipete merged 4 commits into
openclaw:mainfrom
etzelm:fix/update-live-backup-before-swap
Nov 5, 2026
Merged

steipete merged 4 commits into
openclaw:mainfrom
etzelm:fix/update-live-backup-before-swap

Conversation

@etzelm

@etzelm etzelm commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

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 and openclaw/ci-gate passed, including all three PostgreSQL conformance shards. This adds Linux conformance coverage, not the unrun custom-service/upgrade scenario.

…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
@clawsweeper

clawsweeper Bot commented Nov 5, 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 cli CLI command changes size: S labels Nov 5, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 5, 2026
@clawsweeper

clawsweeper Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This 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.

  • Before: The updater can replace the serving installation before database capture refuses ownership, triggering rollback.
  • After: The updater refuses with database-engine-preflight before replacement and tells the operator to stop the Gateway through its service owner.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The focused implementation has no identified code defect, but required shipped-entry-point and upgrade evidence is still absent.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Partial
User problem: An update can replace files used by a serving Gateway before encountering a predictable PostgreSQL backup-ownership refusal.
Reason: Early refusal protects the documented unchanged-install update contract using existing owners; the broader linked issue correctly remains Related rather than closed.

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
Reviewed head: b4fc5cda32dc1228a5a11400b41a4da8b6d8c011

Before merge

  • Add real behavior proof - The supplied evidence exercises executeMutableUpdate with synthetic service discovery, mocked ownership contention, and mocked installation runners; the previous review's real-environment request remains unmet. Provide redacted terminal output or logs from the shipped CLI showing a live PostgreSQL Gateway retains its serving build and files on refusal, followed by successful retry after its service owner stops it, and a latest-stable upgrade with settings and data intact. Redact IPs, API keys, phone numbers, and non-public endpoints. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

None.

Tests

  • Missing end-to-end proof: Supply real CLI/Gateway/PostgreSQL refusal and successful stopped-service retry evidence, plus latest-stable upgrade coverage preserving configuration and data.
Agent review details

How this fits together

The 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]
Loading

Technical review

Best 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

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source +38, Tests -1, Docs +7. Total +44 across 5 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 51 13 +38
Tests 2 139 140 -1
Docs 1 7 0 +7
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 197 153 +44

Preflight source

Source 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

Metric Value Why it matters
Production versus test LOC Production +51/-13; tests +139/-140 The production growth supplies one shared ownership probe and its activation call site; consolidation preserves Git/package retention boundaries while offsetting the new execution scenarios.

Labels

Label changes:

No label changes.

Label justifications:

  • P1: The related report describes repeated serving-Gateway interruptions during updates; stopping the custom service first provides an advanced-operator workaround.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Provide the real PostgreSQL refusal, stopped-service retry, and latest-stable upgrade evidence described in the proof assessment.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-11-05T05:15:38.476Z sha d5630e0 :: needs real behavior proof before merge. :: none

Reviewed November 5, 2026, 12:48 AM ET / 05:48 UTC (Revision 2).

@steipete

steipete commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 5, 2026
@steipete
steipete merged commit 1db0343 into openclaw:main Nov 5, 2026
154 of 158 checks passed
@steipete

steipete commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 6, 2026
…, 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]>
RomneyDa added a commit that referenced this pull request Nov 17, 2026
…, 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes docs Improvements or additions to documentation P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants