Fix bug in market driven queue iteration#4701
Merged
JamesMurkin merged 8 commits intomasterfrom Feb 20, 2026
Merged
Conversation
The CandidateGangIterator assumes that iterators it was passed were ordered - Evicted jobs - Non-evicted jobs So if it ever saw a non-evicted job, it could them just drop the whole queue when `OnlyYieldEvicted` was true However in market based scheduling, that assumption does not hold true and you can get evicted and non-evicted jobs in a mixed ordering This meant if we ever hit something that caused `OnlyYieldEvicted` when using market based scheduling, you could end up preempting many (or all) evicted jobs, depending on the job ordering - as the CandidateGangIterator stopped considering the queue as soon as it saw a non-evicted job Now I've pushed that logic down through the iterator stack - as they are better placed to make the right assumptions - I've also removed the logic about OnlyYieldEvicted dotted all over CandidateGangIterator and it is now contained to their OnlyYieldEvicted/OnlyYieldEvictedForQueue functions Signed-off-by: JamesMurkin <jamesmurkin@hotmail.com>
Signed-off-by: JamesMurkin <jamesmurkin@hotmail.com>
JamesMurkin
commented
Feb 20, 2026
| }, | ||
| PriorityFactorByQueue: map[string]float64{"A": 1, "B": 1}, | ||
| }, | ||
| "reschedules evicted jobs if scheduling limits hit": { |
Contributor
Author
There was a problem hiding this comment.
This test was what covered the original bug
Signed-off-by: JamesMurkin <jamesmurkin@hotmail.com>
Signed-off-by: JamesMurkin <jamesmurkin@hotmail.com>
Signed-off-by: JamesMurkin <jamesmurkin@hotmail.com>
JamesMurkin
commented
Feb 20, 2026
| jobDbTxn := jobDb.WriteTxn() | ||
|
|
||
| // Add all the initial jobs, creating runs for them | ||
| for nodeIdx, jobs := range tc.InitialRunningJobs { |
Signed-off-by: JamesMurkin <jamesmurkin@hotmail.com>
mauriceyap
approved these changes
Feb 20, 2026
|
|
||
| type JobContextIterator interface { | ||
| Next() (*schedulercontext.JobSchedulingContext, error) | ||
| OnlyYieldEvicted() |
Collaborator
There was a problem hiding this comment.
nit: SetOnlyYieldEvicted(onlyYieldEvicted bool) would be nicer
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.
The CandidateGangIterator assumes that iterators it was passed were ordered
So if it ever saw a non-evicted job, it could them just drop the whole queue when
OnlyYieldEvictedwas trueHowever in market based scheduling, that assumption does not hold true and you can get evicted and non-evicted jobs in a mixed ordering
This meant if we ever hit something that caused
OnlyYieldEvictedwhen using market based scheduling, you could end up preempting many (or all) evicted jobs, depending on the job ordering - as the CandidateGangIterator stopped considering the queue as soon as it saw a non-evicted jobNow I've pushed that logic down through the iterator stack - as they are better placed to make the right assumptions