Skip to content

[release-1.12] fix(scheduler): prevent preemptorTasks overwrite in multi-queue preemption and honor QueueOrderFn - #5270

Merged
JesseStutler merged 2 commits into
release-1.12from
copilot/release-1-12-fix-preemptor-tasks-overwrite
Apr 30, 2026
Merged

[release-1.12] fix(scheduler): prevent preemptorTasks overwrite in multi-queue preemption and honor QueueOrderFn#5270
JesseStutler merged 2 commits into
release-1.12from
copilot/release-1-12-fix-preemptor-tasks-overwrite

Conversation

Copilot AI commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

Manual cherry-pick of #5141 and #5142 onto release-1.12 (automated cherry-pick failed due to test file conflicts).

Bug fix (#5141)

In the "Preemption between Task within Job" loop, preemptorTasks[job.UID] was overwritten/drained for all starving jobs regardless of which queue was being processed. With non-deterministic map iteration, this caused preemptors discovered for one queue to be silently lost when another queue was visited first.

Fix: use a scoped intraJobPreemptors queue instead of mutating the shared map.

// Before (buggy): overwrites cross-queue state
preemptorTasks[job.UID] = util.NewPriorityQueue(ssn.TaskOrderFn)

// After: scoped to intra-job pass only
intraJobPreemptors := util.NewPriorityQueue(ssn.TaskOrderFn)

Enhancement (#5142)

  • Replace var underRequest []*api.JobInfo with underRequestByQueue map so intra-job preemption only iterates jobs belonging to the current queue
  • Replace queues map[api.QueueID]*api.QueueInfo{} (non-deterministic iteration) with util.NewPriorityQueue(ssn.QueueOrderFn) for deterministic, plugin-controlled queue ordering — aligning preempt with allocate/reclaim

Tests

  • Regression test for multi-queue preemptorTasks overwrite (was flaky without the fix: ~30% failure rate)
  • Test for priority-based queue ordering via capacity plugin

@volcano-sh-bot volcano-sh-bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 30, 2026
@volcano-sh-bot volcano-sh-bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Apr 30, 2026
…ption and honor QueueOrderFn

Cherry-pick of PRs #5141 and #5142 onto release-1.12.

Changes:
- Replace shared underRequest slice with per-queue underRequestByQueue map
- Use scoped intraJobPreemptors queue instead of overwriting preemptorTasks[job.UID]
- Use QueueOrderFn via util.NewPriorityQueue for deterministic queue traversal
- Add regression tests for multi-queue preemptorTasks overwrite and priority queue ordering

Agent-Logs-Url: https://github.com/volcano-sh/volcano/sessions/344df7f0-d583-4c2c-b425-2a17d053a9f2

Co-authored-by: JesseStutler <38534065+JesseStutler@users.noreply.github.com>
@volcano-sh-bot volcano-sh-bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Apr 30, 2026
Copilot AI changed the title [WIP] Fix preemptorTasks overwrite in multi-queue preemption [release-1.12] fix(scheduler): prevent preemptorTasks overwrite in multi-queue preemption and honor QueueOrderFn Apr 30, 2026
Copilot AI requested a review from JesseStutler April 30, 2026 05:02
@JesseStutler
JesseStutler marked this pull request as ready for review April 30, 2026 06:06
@volcano-sh-bot volcano-sh-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 30, 2026
@volcano-sh-bot
volcano-sh-bot requested a review from Thor-wl April 30, 2026 06:06
@JesseStutler

Copy link
Copy Markdown
Member

/approve
/lgtm

@JesseStutler
JesseStutler merged commit becb484 into release-1.12 Apr 30, 2026
12 of 13 checks passed
@volcano-sh-bot volcano-sh-bot added the lgtm Indicates that a PR is ready to be merged. label Apr 30, 2026
@volcano-sh-bot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: JesseStutler
Once this PR has been reviewed and has the lgtm label, please assign hwdef for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@JesseStutler
JesseStutler deleted the copilot/release-1-12-fix-preemptor-tasks-overwrite branch July 14, 2026 01:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[release-1.12] fix(scheduler): prevent preemptorTasks overwrite in multi-queue preemption

3 participants