Skip to content

fix(cron): replace pending schedule when its expression changes - #64

Merged
psteinroe merged 1 commit into
mainfrom
fix/registration-scope
Oct 2, 2026
Merged

psteinroe merged 1 commit into
mainfrom
fix/registration-scope

Conversation

@psteinroe

@psteinroe psteinroe commented Oct 2, 2026 •

Copy link
Copy Markdown
Owner

Changing a static cron expression now replaces the pending occurrence. Previously the old schedule kept running next to the new one. The PR also documents the "one queue = one codebase" rule that worker registration relies on.

Changed cron expressions

Registration used to match a stale static schedule by (task_key, schedule name) only. Changing 0 0 9 * * * to 0 0 10 * * * under the same name therefore left both the old and the new scheduled::daily::<ts> chains pending forever. _private_register_worker now matches by (task_key, schedule name, cron_expression). Pending old-expression occurrences are deleted, and in-flight ones are cancelled, the same way removed schedules already were. Overdue occurrences of an unchanged schedule are still kept across restarts.

One queue = one codebase

Every orchestrator polling a queue runs the same task set, and separate services use separate queues, the same constraint as Temporal task queues. Registration therefore owns the whole queue, and queue-wide cleanup is intended: it removes schedules and subscriptions of tasks deleted from the codebase.

  • The rule is documented in docs/content/scaling/horizontal.md, with short pointers from the concurrency and cron docs and from AGENTS.md.
  • Known edge case, also documented: during a rolling deploy, an old replica that restarts re-registers the old task set. That removes the cron schedules and event subscriptions that only the new version declares, until a new-version replica starts again. Registration only runs at worker start, so if this happens after the rollout finished, restart one new replica.

Verification

  • New integration test changing a cron expression replaces the pending schedule in cron-scheduling.test.ts. It fails before the fix, and the coordinator's R2 repro passes with it.
  • just lint, just format, bun run typecheck and the full bun test (342 pass) pass on top of current main.

@psteinroe psteinroe changed the title fix(registration): scope cleanup to registered tasks and replace changed cron schedules fix(cron): replace pending schedule when its expression changes Oct 2, 2026
@psteinroe
psteinroe force-pushed the fix/registration-scope branch from 80d1e16 to 5b02801 Compare October 2, 2026 16:38
@psteinroe psteinroe added the ready label Oct 2, 2026
@psteinroe
psteinroe force-pushed the fix/registration-scope branch from 5b02801 to 2264296 Compare October 2, 2026 23:04
@psteinroe
psteinroe force-pushed the fix/registration-scope branch from 2264296 to f157e9d Compare October 2, 2026 23:10
@psteinroe
psteinroe merged commit f998139 into main Oct 2, 2026
9 checks passed
@psteinroe
psteinroe deleted the fix/registration-scope branch October 2, 2026 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant