Repository navigation
fix(doctor): resume schema repair after interrupted migration - #159345
Conversation
Record process identity for schema/media migration leases and reclaim only demonstrably dead process owners. Preserve expiry for work that can outlive its parent, existing snapshots, and transactional migration recovery. Refs #158114. Linux SIGKILL recovery and three focused passes passed; 91 dependent files and changed checks passed; P1 autoreview clean.
|
Codex review: blocked before merge. Reviewed September 26, 2026, 10:55 PM ET / September 27, 2026, 02:55 UTC. ClawSweeper reviewWhat this changesDoctor records process identity on agent schema and media migration leases so a retry can reclaim a lease after its owner dies, with recovery guidance and crash regression coverage. Merge readiness⛔ Blocked before merge - 2 items remain Keep this PR open. Current main still makes an immediate Doctor retry wait for a dead maintenance lease, and the branch addresses that demonstrated recovery failure. The original released startup outage is broader than the Linux retry scenario proved here. Priority: P1 Review scores
Verification
How this fits togetherDoctor repairs existing SQLite state before the Gateway can start. A shared lease controls access to agent database migrations and determines whether repair proceeds or reports another owner. flowchart LR
A[Existing SQLite state] --> B[Doctor repair]
B --> C[Shared migration lease]
C --> D{Lease available or owner dead?}
D -->|No| E[Report held lease]
D -->|Yes| F[Schema and media repair]
F --> G[Gateway startup]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +37, Tests +24, Docs +7. Total +68 across 11 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep Doctor as the migration owner, retain safe dead-process retries and old-lease expiry behavior, and provide a visible Fix or Doctor launcher when an update cannot start the Gateway. Do we have a high-confidence way to reproduce the issue? Yes. The captured PR evidence reports a current-main Linux SIGKILL during Doctor's schema repair followed by an immediate retry refused with OPENCLAW_STATE_LEASE_HELD; the null-payload lease path in source explains that result. Is this the best way to solve the issue? Yes for the demonstrated retry failure. The patch reuses the existing transactional lease owner and dead-process check, while keeping leases without process identity expiry-bound. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 23ad3a56a0b7. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
🦞👀 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. |
…aw#159345) Record process identity for schema/media migration leases and reclaim only demonstrably dead process owners. Preserve expiry for work that can outlive its parent, existing snapshots, and transactional migration recovery. Refs openclaw#158114. Linux SIGKILL recovery and three focused passes passed; 91 dependent files and changed checks passed; P1 autoreview clean.
Closes #158114
What Problem This Solves
Fixes an immediate
doctor --fixretry refusing agent schema/media repair after the previous migration process was killed.User Impact
Operators can rerun Doctor after an interrupted migration and start the Gateway once repair completes. Pending schema changes roll back transactionally, session data stays intact, and the existing pre-migration snapshots remain available. Leases written by older versions without process identity still wait for their existing expiry.
Why This Change Was Made
Current main already moved legacy startup migration into Doctor (#151025); the older report's indefinitely repeated five-minute startup-lease failure was not reproduced on this branch. A Linux SIGKILL replay exposed a remaining recovery gap: the 60-second agent-maintenance lease had no process identity, so the next Doctor attempt refused it as held despite its owner having exited.
The schema/media migration owner now explicitly declares that its writers cannot outlive its process. Lease acquisition records its host, PID, and process start identity and reuses the existing dead-owner reclamation helper inside the admitted write transaction. Other lease users may own surviving Git, installer, or plugin subprocesses, so they retain their existing expiry behavior. No schema, configuration, CLI, or timeout changes are included. Deletion-history holds remain intact.
Thanks @desksk, @NobleVision, and @islandpreneur007 for the detailed recovery evidence.
Evidence
core:agent-database-maintenance/global is held by .... Both new crash regressions failed withOPENCLAW_STATE_LEASE_HELD; graceful exits passed./healthzin 6.076 s. Shared/agentquick_checkboth returnedok.pnpm openclawCLI. This does not claim Windows or a published-updater-driver replay.node scripts/check-changed.mjspassed on Linux, including production typing, all 25 selected test type graphs, lint, formatting, and repository guards.pnpm test src/state/openclaw-state-lease.test.ts --maxWorkers=1: 7 tests passed; 22.05 s command wall (including shared build/setup), 8.17 s Vitest wall, approximately 5.6 s test time. Hosted PR CI duration is pending.LOC: production +43/-6 (net +37); tests/support +37/-13 (net +24); docs +7. The production growth carries the explicit process-lifetime contract through both acquisition transports and keeps subprocess-owning leases conservative.