Skip to content

fix: preserve schedule owner state after lock contention - #2675

Merged
nicobailon merged 4 commits into
nicobailon:mainfrom
quifox:fix/schedule-claim-preservation-current
Oct 4, 2026
Merged

nicobailon merged 4 commits into
nicobailon:mainfrom
quifox:fix/schedule-claim-preservation-current

Conversation

@quifox

@quifox quifox commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Two sessions can read the same due schedule before competing for active.lock. The losing session writes its stale schedule over the winner, erasing activeRunId and allowing deletion while the winning task is running.

The EEXIST branch now reads current state for the skip receipt and local timer only. It never saves the stale schedule or releases the owner's lock. Recurring contenders defer locally without consuming the stored cursor; one-shot contenders stop automatic retry, and an already deleted record stays absent.

Validation: 93 focused tests pass on Linux Node 24, including 7 targeted ownership and timer checks that fail on the original code. Three two-process reproductions cover interval, calendar and one-shot schedules. Typecheck passes. The PR enables the new focused regressions on macOS; the existing unit-test matrix covers Linux and Windows. Exact-head CI remains the merge gate.

Review follow-up (2026-10-04): the macOS job now explicitly runs only the claim contention regression present in this branch. Conditional commands for absent settings, history and launch test files have been removed.

The focused macOS claim check passes. The latest head still has a required Windows integration failure in routes retained workflow follow-ups to distinct outputs without overwriting the writer report; the affected test and foreground executor are unchanged by this PR. Required exact-head CI remains a merge gate.

Final CI check on fbdb1b6f: focused regressions and automated review pass, but test (windows-2) failed: the unchanged retained workflow follow-up integration assertion reported zero running children on Windows. The corresponding focused test passes locally on Linux. Required exact-head CI remains a merge gate; a maintainer rerun is needed to assess the platform failure.

@greptile-apps

greptile-apps Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium risk] Fixes lock contention in scheduled-run state management.

No outstanding code finding was identified; merge readiness still requires confirmation that required CI passed on the exact PR head.

Summary

The PR prevents a session that loses a scheduled-run lock from overwriting the owner's schedule state. It adds focused contention tests, runs them on macOS, and credits the contributor in the changelog.

Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Two sessions read a due schedule] --> B[Compete for active.lock]
  B --> C[Winner claims and persists run]
  B --> D[Loser receives EEXIST]
  D --> E[Read current schedule]
  E --> F{Record still exists?}
  F -- No --> G[Clear local timer]
  F -- Yes --> H[Record skipped overlap]
  H --> I[Defer recurring timer locally or stop one-shot retry]
Loading

Reviews (2) · Last reviewed commit: "ci: run only the claim regressions prese..."

Comment thread .github/workflows/test.yml Resolved
@nicobailon
nicobailon merged commit d67d317 into nicobailon:main Oct 4, 2026
34 of 35 checks passed
@nicobailon

Copy link
Copy Markdown
Owner

Merged, thanks @quifox. A fresh review confirmed the stale-overwrite race on main and that all seven new regressions fail without the fix. The Windows failure was in an unrelated integration test and passed on rerun.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants