Repository navigation
improve(cron): move recovery proposal reads off the caller thread - #153158
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: needs maintainer review before merge. Reviewed September 19, 2026, 5:51 PM ET / 21:51 UTC (Revision 2). ClawSweeper reviewWhat this changesMoves Cron recovery observations into the shared database worker while preserving stop/restart fencing, interruption history, and reservation cleanup. Merge readiness✅ Ready for maintainer review The improvement remains useful, and the previous reservation-cleanup blocker is addressed. No remaining introduced correctness defect was found. Priority: P2 Review scores
Verification
How this fits togetherCron recovers interrupted scheduled jobs using persisted job markers and execution receipts. Startup, timer ticks, and settlement waiters obtain observations from the database worker, then the host validates current ownership before repairing state and resuming scheduling. flowchart TD
A[Startup or timer or settlement wait] --> B[Shared database worker]
C[Stored job markers and receipts] --> B
B --> D[Host lifecycle and liveness checks]
D --> E[Transaction rechecks exact current state]
E --> F[Repair and publish interruption]
F --> G[Resume scheduling or release reservations]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +117, Tests +480, Docs +17. Total +614 across 17 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep observation work in the shared worker while retaining exact-state recovery checks and receipt-specific cleanup with their existing host owners. Do we have a high-confidence way to reproduce the issue? Not applicable as a discrete user-facing bug reproduction: source directly establishes synchronous proposal reads on current main. Runtime measurements were reported by the author, not rerun here. Is this the best way to solve the issue? Yes. Reusing the shared-state worker preserves the existing transaction and recovery owner without introducing a competing store or changing persisted formats. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against fd22b275d548. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Merged via squash.
|
…enclaw#153158) * perf(cron): move recovery proposal observations off-thread * fix(cron): settle retired timer reservations
What Problem This Solves
Cron recovery proposal acquisition still queried SQLite on the caller thread during startup, timer recovery, and run-settlement waits.
User Impact
Those proposal observations now run in the shared-state worker. Cancellation, stop, or restart detected after proposal acquisition prevents obsolete recovery and entry into subsequent scheduling or maintenance. Already committed interruptions keep their history and events across a stop-and-restart during the following reload.
Final recovery writes, execution-authority checks, and guarded saves retain their existing native owners. This does not make the entire Cron flow SQL-free on the caller thread.
Why This Change Was Made
One fixed command preserves the original transaction that observes the active receipt and matching running-marker association, including existing receipt-table initialization. Proposal facts never grant authority: process liveness and local receipt ownership stay on the host, and the final recovery transaction rereads the exact receipt and markers before changing rows. There is no asynchronous work inside that transaction and no schema, retention, configuration, or public API change.
The callers await proposals in their existing order and recheck cancellation and service generation before recovery. Timer recovery collects every proposal before synchronously repairing the batch and starting its notifications. Startup and timer recovery retain committed interruption facts through the canonical reload, then publish them under the same partition lock before a replacement can start catch-up. Lifecycle checks then fence fresh work. Retirement detected after proposal acquisition releases admission and capacity without entering timer maintenance or re-arming the replacement scheduler. A stop or restart during reservation persistence joins the existing receipt-specific cleanup before the timer exits, releasing only its own batch slots. Retirement during an already-running per-agent sweep retains its existing behavior.
Evidence