Skip to content

fix(sm): keep a due schedule when clean_old is set - #1033

Merged
janbjorge merged 2 commits into
mainfrom
fix/clean-old-keeps-due-firing
Oct 24, 2026
Merged

janbjorge merged 2 commits into
mainfrom
fix/clean-old-keeps-due-firing

Conversation

@janbjorge

Copy link
Copy Markdown
Owner

Fixes #1029.

Summary

  • clean_old=True deletes only schedule rows whose cron expression is no longer registered. An unchanged row keeps its next_run, so a firing that came due while the scheduler was down still runs.
  • Removing a schedule by id or entrypoint name still deletes those rows. An empty keep list does not spare anything.

Testing

  • uv sync --frozen && uv run ruff check . && uv run ruff format . --check && uv run lint-imports && uv run mypy . && uv run pytest passed
  • test_schedule_clean_old still drops an expression that is no longer registered, and the kept row keeps its id
  • test_clean_old_keeps_due_firing and test_clean_old_keeps_due_firing_postgres backdate next_run and confirm the same schedule fires after restart
  • test_schedule_lifecycle and test_repository_trace_matches still pass
  • ruff and mypy on the changed modules

Checklist

  • I have read the Contributing Guide
  • I have added or updated tests
  • I have updated documentation if necessary

clean_old deleted every row of the entrypoint, then inserted a
new next_run. A firing that came due while the scheduler was
down was lost even when the expression had not changed.
@janbjorge janbjorge added the Agentic Issue or PR written mainly by an AI agent. Required on all agent-authored contributions. label Oct 24, 2026
The NOT EXISTS subquery was harder to read than the keep list.
An empty keep still deletes every row of the entrypoint. The
clean_old test indexes the kept row with CronExpression.
@janbjorge
janbjorge merged commit deac8eb into main Oct 24, 2026
21 checks passed
@janbjorge
janbjorge deleted the fix/clean-old-keeps-due-firing branch October 24, 2026 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Agentic Issue or PR written mainly by an AI agent. Required on all agent-authored contributions.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SchedulerManager clean_old=True deletes unchanged schedules too, so a firing due during a restart is lost

1 participant