Repository navigation
scheduler: unclaimed schedule jobs expire at their claim deadline - #184
Merged
Merged
Conversation
A scheduled job no agent has claimed within one cron interval plus the two-minute grace is rejected by the scheduler tick, with a schedule-job-cancel audit row (reason claim_deadline_expired). This replaces the #183 stale special case in runSchedule (stale-overlap filter, left-out targets, all-stale skip); the manual cancel API stays.
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.
What
Unclaimed scheduled jobs now expire on their own at a claim deadline, instead of #183's special case that only stopped them from blocking overlap.
scheduleStaleNotStartedCutoff), measured fromjobs.created_at. It is derived, not stored, so there is no migration.Store.ExpireScheduleJobs(now)runs at the start of everyTickSchedulescall (every 30 s inscheduleLoop).not_startedjobs with no lease that belong toschedule_jobsand are past the deadline. The read query is driven by the existingjobs(state, created_at…)index.rejectedwith a guardedUPDATE … WHERE state='not_started' AND lease_token IS NULL. This is the same transition the manual cancel uses.schedule-job-cancelaudit row per job:auth_subject=scheduler:<name>,reason=claim_deadline_expired, plus the machine id.schedule_jobs. Profile-assignment and other jobs are never touched, and neither are claimed or leased jobs.Removed (#183 special case)
NOT (...)clause in the overlap countscheduleStaleTargetsTxand the per-run "left out N target(s)" exclusionThe manual
POST /v1/operator/schedule-jobs/{id}/cancelstays; it is now only needed to clear a job sooner.Behaviour is unchanged for overlap timing. An unclaimed job still blocks exactly the slot right after its own and is gone before the slot after that. The difference is that the offline machine gets a fresh job in that run instead of being left out.
The morning report's reason text for a rejected scheduled job now reads "rejected the check or never picked it up".
Tests
TestScheduleJobClaimDeadlinecovers:claim_deadline_expiredTestScheduleJobClaimDeadlineClearsExistingStuckJobs: a job on a dropped target under a disabled schedule is cleared on the first sweep, and a second sweep is a no-op.Deploy / rollback