Skip to content

fix(update): wait for SQLite maintenance before managed activation - #176131

Merged
steipete merged 2 commits into
mainfrom
upd/upd-l1683
Oct 18, 2026
Merged

steipete merged 2 commits into
mainfrom
upd/upd-l1683

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Managed Git updates could stop the serving Gateway and then abort before checkout when the recovery-state guard encountered another process's native SQLite maintenance lease.

Fixes #175913

User Impact

Short maintenance operations can finish while the updater waits. A persistent owner defers activation before stopping the Gateway; contention appearing after shutdown retains the existing rollback path. The diagnostic identifies the owner's PID and role and tells the operator to let maintenance finish before retrying.

Why This Change Was Made

The update execution owner now uses a bounded asynchronous recovery/authority check at admission, activation, native stop, and pre-checkout boundaries. It retries only the read, never a mutation, for at most 30 seconds within the invocation's existing deadline. The synchronous effect guards remain, and every attempt checks requester revocation and retained executor authority. A deadline expiring during known maintenance retains the maintenance failure classification and rollback eligibility; unrelated cancellation and schema/recovery failures still propagate.

The producer audit found awaited native custody in update database capture and Doctor, and another possible acquisition path in CLI startup plugin-source cleanup. The incident's historical holder is not identifiable from the retained report; this change neither guesses that identity nor takes over a foreign live lease.

Evidence

  • A real child holds acquireGatewayLock({ role: "sqlite-maintenance" }). Reinstating the original execution owner reproduces immediate native maintenance refusal before stop and before checkout. The repaired orchestration waits or defers, preserves restart eligibility after stop, and detects fresh recovery, requester revocation, interruption, and deadline expiry.
  • Live isolated source reproduction: the guard passed before the lease; waited 363 ms and proceeded after release; a persistent lease deferred after 30,004 ms with PID/role and retry guidance; the guard passed again after release. No operator Gateway or state was used.
  • Focused tests: eight passing cases, including the production sleep's abort wrapper. Build and service adapters are fixture boundaries; this is not a full package-install or operating-system service-manager replay.
  • Direct/re-export sibling run: 115 files passed, 5 skipped, no failures (120 selected files; 1,785 s including runtime preparation). The skips require PostgreSQL test configuration, Linux-only immutable activation, or other platform gates.
  • After removing the unused synchronous wrapper, the three-file eager-import/recovery/native-contention check also passed.
  • Production and CLI test typechecks, touched-file oxlint/oxfmt, import-cycle check, and independent Codex review.
  • The SQLite inventory phase of check:changed was skipped locally for time; scoped checks above ran, and PR CI supplies broad proof.

Production: +81/-35 LOC. Tests: +204/-0 LOC, plus one test-routing line. Documentation: +9/-0 LOC. No config, CLI option, dependency, or schema change.

Reproducible focused commands and existing suite cost

Run with an isolated HOME and OPENCLAW_STATE_DIR:

node scripts/run-vitest.mjs src/cli/update-cli/update-command-maintenance-contention.test.ts --maxWorkers=1
node scripts/run-tsgo.mjs -p tsconfig.core.json
node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.cli-update.json
node --import ./scripts/tsx.mjs scripts/check-madge-import-cycles.ts

The broad run rebuilt the runtime in 77.5 s. Existing process-heavy files exceeded 120 s of reported case time: update-command-original-service.test.ts (142.9 s), update-command-database-rollback.test.ts (139.2 s), update-command-lease.test.ts (131.9 s), and update-cli.windows-lifecycle.test.ts (131.0 s). These exercise fresh package/service/database or executor fixtures across many scenarios; none was weakened, retried to chase green, or given a longer timeout.

Wait for transient foreign state maintenance before stopping the Gateway and before Git checkout. Preserve live authority, recovery detection, cancellation, and rollback eligibility when the wait expires. Fixes #175913.
@clawsweeper

clawsweeper Bot commented Oct 18, 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.

@steipete
steipete marked this pull request as ready for review October 18, 2026 07:32
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-18T07:35:43.916021Z 3c2a049 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation cli CLI command changes size: M labels Oct 18, 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. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. 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 Oct 18, 2026
@clawsweeper

clawsweeper Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: stale review; fresh review needed.

Summary
The latest durable ClawSweeper review was for head 3c2a049a7b7e65b5c1883e3457362d977016bff2, but the PR head is now 179082a6e5420567bd3bafd1bba626ecca19db7f. Its old verdict and PR readiness labels are no longer current.

Next step
Run or wait for a fresh ClawSweeper review on the current PR head.

Review history (1 earlier review cycle)
  • reviewed 2026-10-18T07:48:41.980Z sha 3c2a049 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 18, 2026
@steipete
steipete merged commit c57ba36 into main Oct 18, 2026
142 checks passed
@steipete
steipete deleted the upd/upd-l1683 branch October 18, 2026 08:24
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 19, 2026
…176131)

A managed Git update could stop the serving Gateway and then abort before checkout because its execution guard hit a foreign SQLite maintenance owner, falling back to the previous build. The guard now waits for foreign maintenance (at most 30 s and never past the update deadline, cancellable) before stopping the Gateway and before checkout, retrying only the guarded read; authority and recovery checks are unchanged, and on expiry the update defers with the maintenance owner's PID/role and stays rollback-eligible.

Fixes openclaw#175913
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 P2 Normal backlog priority with limited blast radius. size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Managed Git update aborts before checkout when recovery-state guard meets foreign maintenance after service stop

1 participant