Repository navigation
fix(update): wait for SQLite maintenance before managed activation - #176131
Conversation
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.
|
🦞👀 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 SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: stale review; fresh review needed. Summary Next step Review history (1 earlier review cycle)
|
…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
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
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.check:changedwas 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
HOMEandOPENCLAW_STATE_DIR: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), andupdate-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.