Skip to content

fix(cron): don't cancel an executing job when re-arming the timer#3165

Open
nankingjing wants to merge 1 commit into
volcengine:mainfrom
nankingjing:fix/cron-arm-timer-cancels-job
Open

fix(cron): don't cancel an executing job when re-arming the timer#3165
nankingjing wants to merge 1 commit into
volcengine:mainfrom
nankingjing:fix/cron-arm-timer-cancels-job

Conversation

@nankingjing

Copy link
Copy Markdown
Contributor

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 _executing guard 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).

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.
@nankingjing

Copy link
Copy Markdown
Contributor Author
Self-reviewed: diff is correct, minimal, and well-tested. No issues found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

1 participant