Repository navigation
fix: preserve maintenance leases during slow heartbeat renewal - #157696
Conversation
|
🦞👀 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: blocked before merge. Reviewed September 24, 2026, 8:15 PM ET / September 25, 2026, 00:15 UTC (Revision 2). ClawSweeper reviewWhat this changesThe branch lets maintenance lease checks wait for a slow SQLite heartbeat renewal, using worker progress to extend bounded liveness checks and adding regression coverage. Merge readiness⛔ Blocked before merge - 3 items remain The fix remains needed: current main and v2026.9.6 still use a one-second heartbeat response deadline. The earlier async no-reply finding is addressed on this head. A maintainer should resolve the synchronous stall tradeoff before merge. Priority: P1 Review scores
Verification
How this fits togetherOpenClaw uses a dedicated worker to renew maintenance leases stored in SQLite. Lease callers check worker responsiveness and persisted ownership before continuing protected maintenance work. flowchart LR
A[Maintenance caller] --> B[Lease owner]
B --> C[Heartbeat worker]
C --> D[SQLite lease row]
C --> E[Renewal progress]
E --> F[Bounded response check]
D --> G[Ownership recheck]
F --> G
Decision needed
Why: The change trades false lease loss on slow storage for a longer possible caller stall; source and tests establish the bounds but cannot choose the acceptable Gateway responsiveness policy. Before merge
Agent review detailsSecurityNone. PR surfaceSource +48, Tests +126. Total +174 across 5 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the slow-renewal tolerance and final persisted-owner check, with an owner-approved bound for synchronous waits after an unresponsive worker. Do we have a high-confidence way to reproduce the issue? Yes. Current main has the fixed one-second deadline, and the PR reports an actual-worker assertion failure at 1,002 ms with ample durable lease time remaining; this read-only review did not execute it. Is this the best way to solve the issue? Unclear. Progress-aware waiting repairs the observed false loss while retaining durable checks, but the acceptable synchronous stall duration requires an owner choice. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 943236e581dc. 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
HistoryReview history (1 earlier review cycle)
|
|
@clawsweeper re-review Addressed the async renewal-completion finding at |
|
🦞👀 Re-review progress:
|
|
Merged via squash auto-merge.
|
* commit '05edd36e124dc376f63475256f45e82ec437412c': (30 commits) refactor(matrix): reuse bounded direct-room cache insertion (#157775) fix: preserve channel-owner revocation across recovery (#157709) fix(ci): stop blocking CI during release validation (#157757) refactor(tlon): remove unreachable DM summary branches (#157789) chore: speed up worktree recovery tests with Bun (#157674) fix(sessions): release PR caches when pending viewers leave (#157776) refactor(twitch): reuse setup account selection (#157787) test: skip empty task ledger resets in cron fixtures (#157767) perf: reduce gateway and state test startup (#157711) fix: preserve maintenance leases during slow heartbeat renewal (#157696) fix(channels): match non-TTY setup advice to registered flags (#157551) fix: keep failed update report uploads in the CLI (#156633) fix: preserve rejected settings reason when opening config (#157731) test(update): load real filesystem dependencies in swap fixture fix(ci): prevent Security Review checkout retry collisions (#157652) fix(ci): recover interrupted Security Review response bodies (#157651) test(ui): capture live operator authority in guest question fixture refactor(agents): deslop runners, harness and recovery (#157294) fix(auth): preserve Copilot tenant credentials during Doctor repair (#139131) refactor(msteams): share stored service URL validation (#157706) ...
…law#157696) * fix: preserve maintenance leases during slow heartbeat renewal * fix: recheck heartbeat responses after native renewal
Backport #157696: 09e30a1 Backport #157733: 136ce55 Selected backport #157730: 942a27d Required test prerequisite #156037: 1f55d63 Keep heartbeat progress distinct from authority, settle repair-owned resources before maintenance, and validate complete source content before reusing decoded Doctor rows. Preserve the frozen runtime-entrypoint owner and its standalone child protocol. Schema remains v18. Source-bound targeted/native/built-child proof and independent review pass. This is not a published-package or native service-recovery qualification. Co-authored-by: Jason (Json) <[email protected]> Co-authored-by: RomneyDa <[email protected]> Co-authored-by: vyctorbrzezowski <[email protected]> Co-authored-by: steipete <[email protected]> Co-authored-by: jalehman <[email protected]>
Related: #157160
What Problem This Solves
Fixes false maintenance lease loss when a valid heartbeat worker takes more than one second to finish a native SQLite renewal.
User Impact
Maintenance can wait for a slow renewal without treating an occupied worker as dead. Expired or replaced owners and workers that do not acknowledge the request still fail closed. No settings, schema or migration changes are required.
This addresses a reproduced post-acquisition heartbeat failure. It does not establish the cause of the reported incident or replace the separate Gateway acquisition work in #157413.
Why This Change Was Made
The heartbeat now publishes renewal progress so response checks can distinguish native work from an idle unresponsive worker. Progress only permits bounded waiting; it never grants ownership. Fresh replies, lease expiry and the caller's durable ownership recheck remain mandatory. Async requests recheck at bounded intervals so renewal finishing without a reply cannot leave a request asleep until lease expiry.
Synchronous wait tradeoff — accepted
The final ClawSweeper review confirms the async finding is resolved and reports no actionable code defects. Its remaining decision is resolved here: retain the existing durable lease as the synchronous wait ceiling. If a worker exits abruptly while its renewal-progress marker is in flight, the caller can stall until that observed lease expires (up to the 60-second maintenance lease), because JavaScript cannot deliver the exit callback during the synchronous wait.
This is an explicit bounded availability tradeoff in this repair, not a claim that worker death is always detected within one second. A shorter unmeasured cap would restore false lease loss for valid slow storage. Progress never grants authority: a fresh acknowledgment and a final durable-owner check are mandatory, and the expiry control rejects an occupied worker at the original observed deadline. No indefinite wait, lease extension from progress, configuration change, or weakening of write authorization is introduced. Internal scheduling and lifecycle selection are within the authorized repair-and-land scope.
Evidence
0484d7a3ecf52589b0d3d98741e58e5f6b5bf661with the three published production blobs: real maintenance scope, one callback, two SQLite write transactions, 1,505 ms delayed-COMMIT wait, final write retained, worker joined, and zero lease rows. Parent/worker source hashes verify the published fix and new maintenance-scope/cache implementations; private fixtures were removed.Measured test cost
Canonical macOS arm64 runs with repository-pinned pnpm and
--maxWorkers=1:openclaw-state-lease-heartbeat.lifetime.test.tsopenclaw-state-lease-heartbeat.activation.test.tsCommands:
pnpm test src/state/<file> --maxWorkers=1. CI values are sums of rounded per-case reporter times, not file wall time; they exclude import/setup. Both jobs passed onf307fbb8cc8804807367a18ed2c941a8df3fc02f. The shared lifetime job took 359 s and the shared activation job took 675 s, including other files and setup.Post-merge CI cleanup
After verified merge, the redundant recovery of the original release-deferred PR run (36076042946, attempt 2) was canceled to retire its remaining duplicate work. Its final census had no failed jobs (40 passed, 95 canceled, 18 skipped). The complete exact-head validation remains 36076724801: success, and the required combined gate 36081896041 passed before merge.