Repository navigation
Fix rescheduling recreated dynamic tasks - #793
Merged
Merged
Conversation
rosa
force-pushed
the
fix/reschedule-recreated-dynamic-tasks
branch
from
November 3, 2026 11:15
2939e3d to
f780057
Compare
Member
|
Thanks a lot for this, @saidM, and sorry it took us so long! The bug is real, and your fix was correct. I rebased it onto main and added one commit on top that keeps the same behaviour with less bookkeeping: the scheduler now tracks scheduled tasks by record id instead of by key. A task that's deleted and created again gets a new id, so the existing steps that schedule new tasks and unschedule deleted ones handle it, and a run only schedules the next one if its task is still in the schedule. That replaces the map from keys to ids and the active flag. Your tests are unchanged apart from looking tasks up by id, and I froze time in the in-place update test so a run at the top of the hour can't land between its two lookups. |
A task that's deleted and created again with the same key gets a new id, so keying the in-memory schedule by id lets the existing steps that schedule new tasks and unschedule deleted ones handle it, without a second map from keys to ids or a separate active flag. A run only schedules the next one if its task is still in the schedule, which also covers a replaced task and a stopped scheduler. The database query for dynamic tasks now runs before taking the lock, so it doesn't hold up a task that's due. Polling now only unschedules dynamic tasks. A static task whose row is deleted keeps running until the scheduler restarts, when it reads the configuration again. Also freeze time in the test for tasks updated in place, so a run at the top of the hour can't land between its two lookups. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
rosa
force-pushed
the
fix/reschedule-recreated-dynamic-tasks
branch
from
November 3, 2026 16:57
f780057 to
6a1d79e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #792.
The scheduler reconciles dynamic tasks by key, so a task removed and recreated with the same key between polls currently looks unchanged.
This change tracks the database record associated with each scheduled dynamic task. When the same key points to a new record, the old timer is cancelled and the replacement is scheduled. It also prevents a callback from the previous task from restoring the old schedule.
Direct updates to an existing task record remain unchanged, as documented.
Testing