Skip to content

fix(update): PostgreSQL update spends minutes validating the candidate before refusing a Gateway it cannot stop - #196157

Merged
vincentkoc merged 5 commits into
openclaw:mainfrom
etzelm:fix/update-postgres-owner-before-validation
Nov 10, 2026
Merged

vincentkoc merged 5 commits into
openclaw:mainfrom
etzelm:fix/update-postgres-owner-before-validation

Conversation

@etzelm

@etzelm etzelm commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Related: #193163
Related: #196154
Follow-up to #193190

What Problem This Solves

openclaw update can spend minutes running candidate validation before refusing at database-engine-preflight when a PostgreSQL Gateway holds state ownership and the updater will not stop it.

User Impact

Refuse before canary validation with the existing ownership reason and next step, preserving the installation and running Gateway. Runtime retention and candidate installation still occur first. Managed services the updater will stop, separately parked foreground updates, stopped Gateways and SQLite-only installs retain their behavior.

Why This Change Was Made

The existing preactivation probe protects the installation, but runs after validation. Reuse it at the candidate-validation owner boundary when neither a future managed stop nor foreground park can release ownership. Keep the final probe for an owner that starts later. Keep the probe inside the validation error boundary so package installs retain database-engine-preflight rather than global-install-failed.

Maintainer correction f8d69b280dd8de97718898bbd5e73d19c2b10194 passes the managed exemption only when shouldRestart is true. A running owned or unresolved service under --no-restart therefore refuses early. The foreground parking exemption remains separate.

Full PR production delta: +45 net lines for this early ownership boundary; correction production delta: 0. Tests: +188, allocated in the task's own test-line record; shared cap unchanged. No schema, auth, restart-policy, cancellation or capture-durability change.

Evidence

  • Exact signed head: f8d69b280dd8de97718898bbd5e73d19c2b10194.
  • Independent full-range source review resolved its sole old-index finding by staging the explicitly reviewed correction. A later fixture-only field completes the existing owned-service verdict type; no unresolved source finding. Bounded independent final proof review found the runtime gap resolved.
  • Required exact-head CI: completed success. CI's build job was skipped; it is not counted as build proof.
  • Fresh Blacksmith Testbox tbx_01m73e8gxsc0atpmskka05jv9s, allocation run, exact head verified: update-command-execution.test.ts, update-command-foreground.test.ts and update-command-candidate-validation.test.ts all passed, 102 tests in 3 files (77.91 s).
  • Full pnpm build passed on that exact source; installed CLI reports OpenClaw 2026.11.2 (f8d69b2). The build also reported CSS/chat-boot budget warnings; no claim that every asset budget passed. The PR changes only update CLI source/tests and its allocation record.
  • Formatting, diff checks and signed commit hooks passed. Original author evidence (179 tests, red/green controls and a stable-package/Git PostgreSQL upgrade trace) remains historical; it does not substitute for corrected-head proof.

Corrected-head installed CLI behavior

On the same isolated Linux Testbox, the canonical package helper produced and installed the exact-head package into a separate npm prefix. A uniquely named canonical profile was installed through the real user-systemd owner with PostgreSQL 17, a file SecretRef and normal token auth.

The repository's existing packFirstHopUpdateFixture produced a distinct 2026.11.3-first-hop.0 candidate from that package. Its complete member-digest receipt changed only package.json, dist/build-info.json and dist/postinstall-content-inventory.json; compiled runtime bytes were unchanged. An earlier identical-artifact run correctly returned already-current and is excluded from defect proof.

Actual installed entry point:

openclaw --profile <isolated-profile> update \
  --tag file:<candidate-next.tgz> --yes --no-restart --json
exit=1 status=error reason=database-engine-preflight elapsed=55.911s
steps=updater-runtime-retention, package-install, package-update, gateway recovery observation
candidate canary validation steps=none

Preliminary candidate admission ran; canary snapshot/Doctor/lint/config/plugins/recovery/Gateway validation did not. Before and after refusal:

  • All 24,042 hashed core package files were unchanged.
  • Native service PID, process start identity and systemd start timestamp were identical.
  • Authenticated Gateway RPC and HTTP readiness succeeded.
  • PostgreSQL marker data was unchanged.

Native installation initially refused the runner's existing world-writable ancestor. Only the absent private service directories were created; existing permissions, manager configuration and the guard were unchanged.

Review follow-through and limits

The previous exact-head review had zero source findings and required the installed managed PostgreSQL --no-restart proof above. That proof is now complete. Native preparation, enforced checks and landing remain required.

Credit: @etzelm for the original repair and historical qualification. No Team deployment, production-instance, cross-host continuity or crash/remote-acceptance claim.

- Probe PostgreSQL capture ownership before candidate validation unless
  the owner can still be released before activation
- Exempt running services the updater stops (owned or unresolved) and
  Gateway-started foreground runs, which park their Gateway after
  validation
- Share the foreground parking condition with the activation handoff
- Pass the pre-stop service state into candidate validation
- Keep the existing probe before activation for owners that start later
- Add tests: held owner refuses before validation for Git and package
  installs; owned and unresolved running services and a foreground run
  still reach validation
@clawsweeper

clawsweeper Bot commented Nov 9, 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.

@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. P2 Normal backlog priority with limited blast radius. 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 9, 2026
@clawsweeper

clawsweeper Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Check PostgreSQL backup ownership before expensive candidate validation when the updater has no planned shutdown that could release it.

Example: Run openclaw update --yes --no-restart --json while a managed PostgreSQL Gateway holds state ownership.

  • Before: Candidate validation runs before the update refuses with database-engine-preflight.
  • After: The update refuses before canary validation, preserving the installation, running Gateway and PostgreSQL data.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Focused repair with shipped-entry proof, exact-head CI and no open correctness, security or product concern; persisted formats and migration behavior are unchanged.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): Exact-head installed CLI output exercises a real native user-systemd PostgreSQL 17 Gateway under --no-restart and records database-engine-preflight before canary validation, with package bytes, Gateway process identity, authenticated readiness and marker data preserved; this resolves the unchanged head's previous proof hold.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: An update spends minutes validating a candidate before reporting an ownership obstruction it could detect earlier.
Reason: The narrow fix saves unnecessary work while preserving the established refusal and shutdown contracts, with explicit maintainer involvement.

Merge readiness

✅ Ready for maintainer review

This PR provides a useful, focused fix with no actionable findings; the new installed-CLI evidence resolves the previous proof hold.

Priority: P2
Reviewed head: f8d69b280dd8de97718898bbd5e73d19c2b10194

Before merge

None.

Findings

None.

Agent review details

How this fits together

The update CLI prepares Git or package candidates, validates them, coordinates Gateway shutdown and checks database ownership before activating the installation.

flowchart TD
  A[Update CLI] --> B[Prepare candidate]
  B --> C[Check ownership and planned shutdown]
  C --> D[Refuse with retry guidance]
  C --> E[Validate candidate]
  E --> F[Stop or park Gateway]
  F --> G[Recheck ownership]
  G --> H[Activate and capture databases]
Loading

Technical review

Best possible solution:

Retain this focused early refusal while preserving planned shutdowns, foreground parking and the final preactivation ownership check.

Do we have a high-confidence way to reproduce the issue?

Current-main source validates the candidate before checking PostgreSQL capture ownership, matching the reported wasted work; supplied installed-CLI evidence exercises the corrected refusal path.

Is this the best way to solve the issue?

This is the smallest complete fix: reuse the existing ownership probe at candidate validation, exempt only planned shutdown paths and preserve its package error classification.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 474b4cebd95f.

Provenance checked

  • PostgreSQL capture ownership keeps the original intent (1db0343: Refuse before replacing a serving installation when PostgreSQL backup cannot obtain exclusive ownership.)
  • Validation before managed shutdown keeps the original intent (d1a69c0: Prepare and validate candidates while the Gateway serves, stopping it only for activation.)
  • Foreground parking condition keeps the original intent (9b3f350: Keep the foreground Gateway serving through validation and park it before replacing runtime files.)
  • Validation error classification keeps the original intent (b107d4a: Preserve preparation failure reasons through package update handling and recovery.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Mitchell Etzel: Raw commit 1db0343 adds src/cli/update-cli/update-command-database-backup.ts:63 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 1db0343a0c0d; files: src/cli/update-cli/update-command-database-backup.ts)

PR surface

Source +45, Tests +188, Other +2. Total +235 across 7 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 4 75 30 +45
Tests 2 188 0 +188
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 7 265 30 +235

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 growth Production +75/-30; tests +188/-0 Growth reuses existing ownership and handoff mechanisms; tests cover Git/package refusal, managed restart exemptions and foreground parking.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: Avoids expensive validation before an inevitable PostgreSQL ownership refusal without changing the existing update safety policy.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

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 (4 earlier review cycles)
  • reviewed 2026-11-09T17:44:09.241Z sha f504db0e857ce7ac13cbaf67bac3a5f4ee225126 :: needs real behavior proof before merge. :: none
  • reviewed 2026-11-09T20:47:12.748Z sha f82b55eeab9b29520fc2f7c83a6ce4866097daac :: needs real behavior proof before merge. :: none
  • reviewed 2026-11-10T00:31:17.265Z sha 1d5061e :: needs maintainer review before merge. :: none
  • reviewed 2026-11-10T19:07:39.517Z sha f8d69b2 :: needs real behavior proof before merge. :: none

Reviewed November 10, 2026, 2:45 PM ET / 19:45 UTC (Revision 5).

@etzelm

etzelm commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 9, 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. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 9, 2026
- The early PostgreSQL owner probe throws inside candidate validation; the
  package runner reported that as global-install-failed
- Extend the existing validation try block over the config read and
  candidate validation so the refusal keeps database-engine-preflight
- The package test's runner mock now returns a failed result for a thrown
  validation error, as the real package runner does
- Raise the test-lines allocation from 172 to 181
@etzelm
etzelm force-pushed the fix/update-postgres-owner-before-validation branch from f82b55e to 1d5061e Compare November 10, 2026 00:25
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Nov 10, 2026
@vincentkoc vincentkoc self-assigned this Nov 10, 2026
@vincentkoc vincentkoc closed this Nov 10, 2026
@vincentkoc vincentkoc reopened this Nov 10, 2026
@vincentkoc

Copy link
Copy Markdown
Member

@clawsweeper re-review

Please review exact head f8d69b280dd8de97718898bbd5e73d19c2b10194. The maintainer correction resolves the managed-owner --no-restart exemption at the candidate producer; restart-enabled and foreground-parking paths remain separate. The PR body records the correction, original proof limits, and current exact-head CI. Focus on this ownership boundary and introduced regressions. Required runtime/CI proof remains pending; this requests read-only review only.

@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Nov 10, 2026
@vincentkoc

Copy link
Copy Markdown
Member

@clawsweeper re-review

Exact head f8d69b2 is unchanged. New proof resolves the existing hold: actual installed CLI against real native user-systemd PostgreSQL17 Gateway under --no-restart refused database-engine-preflight before canary validation (55.911s);24042core file hashes, native PID/start identity, authenticated RPC/readiness and PGmarker unchanged. Canonical future fixture changed only package/build-info/content-inventory metadata; compiled runtime unchanged.102focused tests, full build and required exact-head CI passed. Body has exact receipts and limitations. Please assess the remaining proof hold; no source changes or new scope.

@clawsweeper

clawsweeper Bot commented Nov 10, 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-repro Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 10, 2026
@vincentkoc
vincentkoc merged commit 2a41138 into openclaw:main Nov 10, 2026
192 of 258 checks passed
@vincentkoc

Copy link
Copy Markdown
Member

Merged via squash.

@etzelm
etzelm deleted the fix/update-postgres-owner-before-validation branch November 10, 2026 19:49
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 11, 2026
…e before refusing a Gateway it cannot stop (openclaw#196157)

* fix(update): refuse unreleasable PostgreSQL owner before validation

- Probe PostgreSQL capture ownership before candidate validation unless
  the owner can still be released before activation
- Exempt running services the updater stops (owned or unresolved) and
  Gateway-started foreground runs, which park their Gateway after
  validation
- Share the foreground parking condition with the activation handoff
- Pass the pre-stop service state into candidate validation
- Keep the existing probe before activation for owners that start later
- Add tests: held owner refuses before validation for Git and package
  installs; owned and unresolved running services and a foreground run
  still reach validation

* test: allocate test lines for PostgreSQL owner refusal regressions

* fix(update): keep owner refusal reason for package installs

- The early PostgreSQL owner probe throws inside candidate validation; the
  package runner reported that as global-install-failed
- Extend the existing validation try block over the config read and
  candidate validation so the refusal keeps database-engine-preflight
- The package test's runner mock now returns a failed result for a thrown
  validation error, as the real package runner does
- Raise the test-lines allocation from 172 to 181

* fix(update): only exempt owners the updater will stop

* test(update): provide complete managed owner verdict

---------

Co-authored-by: Vincent Koc <[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 P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants