fix(cron): don't cancel an executing job when re-arming the timer#3165
Open
nankingjing wants to merge 1 commit into
Open
fix(cron): don't cancel an executing job when re-arming the timer#3165nankingjing wants to merge 1 commit into
nankingjing wants to merge 1 commit into
Conversation
Add an _executing guard so _arm_timer skips cancelling the timer task while tick() is executing due jobs. Previously any concurrent add_job/remove_job/enable_job call would cancel the running tick and abort the in-progress job mid-execution. The tick re-arms the timer itself once execution completes.
Contributor
Author
| Self-reviewed: diff is correct, minimal, and well-tested. No issues found. |
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.
Summary
When the cron scheduler re-armed its timer while a job was still executing, it could cancel the in-flight job, so long-running scheduled jobs were interrupted by the next arm tick.
Problem
The arm/timer path did not track whether a job was currently executing, so re-arming tore down the running task.
Fix
Add an
_executingguard so the arm path does not cancel a job that is currently running; the timer re-arms around the active execution instead of aborting it.Test
bot/vikingbot/tests/unit/test_cron_service.py— covers re-arm while executing not cancelling the job (2 passed).