Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert cron jobs to async calls #2197

Closed
alecthomas opened this issue Jul 30, 2024 · 0 comments · Fixed by #2407
Closed

Convert cron jobs to async calls #2197

alecthomas opened this issue Jul 30, 2024 · 0 comments · Fixed by #2407
Assignees
Labels
techdebt Issue is technical debt

Comments

@alecthomas
Copy link
Collaborator

Currently cron jobs have their own bespoke execution system. To take advantage of retries, catch, etc. we should convert these to use async.

@alecthomas alecthomas added the techdebt Issue is technical debt label Jul 30, 2024
@alecthomas alecthomas self-assigned this Jul 30, 2024
@ftl-robot ftl-robot mentioned this issue Jul 30, 2024
@alecthomas alecthomas removed their assignment Aug 1, 2024
@alecthomas alecthomas added the next Work that will be be picked up next label Aug 1, 2024
@safeer safeer self-assigned this Aug 8, 2024
@github-actions github-actions bot removed the next Work that will be be picked up next label Aug 8, 2024
github-merge-queue bot pushed a commit that referenced this issue Aug 23, 2024
This refactor removes the cron job system's state management, cron
execution, and hashring management, in favor of the async call system.

Data tables changed as follows:
- `cron_jobs` is still used to maintain the job list
- Removes `state`, adds `last_execution::timestampz` and
`last_async_call_id::bigint`
- `async_calls` is inserted to by the cron system
  - `cron_jobs.last_async_call_id = async_calls.id`
  - Adds the notion of a `cron` origin in `async_calls.origin`

After a deployment, all valid unscheduled cron jobs are scheduled; a row
is added to `async_calls` with a `pending` state and `scheduled_at` is
set to the job's next execution time. The corresponding row in
`cron_jobs` is also updated with the scheduled async call, the computed
next execution time, and the inserted async call ID.

On completion of a cron async call, the next execution of that job is
scheduled. Effectively, every cron job will have exactly one scheduled
execution.

Closes #2197

---------

Co-authored-by: Alec Thomas <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
techdebt Issue is technical debt
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants