Skip to content

router: fix session boost grace hold being skipped - #1975

Open
Abhayanthk wants to merge 1 commit into
volcano-sh:mainfrom
Abhayanthk:fix/router-session-boost-grace-hold
Open

Abhayanthk wants to merge 1 commit into
volcano-sh:mainfrom
Abhayanthk:fix/router-session-boost-grace-hold

Conversation

@Abhayanthk

Copy link
Copy Markdown
Contributor

What type of PR is this?
/kind bug

What this PR does / why we need it:
When a grace period is set, a slot freed by a finished request should be held for a same-session follow-up until the grace period ends. While testing go test -race on main, I saw TestSessionBoostQueue_GracePeriod_NoBoostArrives fail with "Dequeue happened too early (before grace period)".

The cause is a small timing window. Release first lowers the inflight count and then sends the release signal. The arrival path checks the release signal first and then reads the inflight count. If a release lands between those two reads, the arrival path sees no pending release but does see the free slot, so it admits a waiting request right away and the grace hold is skipped.

The fix makes both sides read the same state. Release now lowers the count and sends the signal under a new releaseMu. The arrival path reads the release signal and the inflight count together under the same lock, and then admits only above the count it read. A slot freed after that read stays held for the grace path.

I added a test case that frees a slot in the middle of the arrival handling. It fails on main and passes with the fix.

Which issue(s) this PR fixes:
None

Bug evidence (required for bug-related PRs):

  • On main, TestSessionBoostQueue_GracePeriod_NoBoostArrives failed once in 3 full -race runs of the make test packages.
  • With a 20 ms sleep added in Release between the decrement and the signal, the same test fails 20 out of 20 times on main and 0 out of 20 with the fix.
  • The new table case fails 20 out of 20 times on main and passes 20 out of 20 with the fix.

Special notes for your reviewer:
I used AI tools while working on this and verified everything myself.

Does this PR introduce a user-facing change?:

Fixed a race in the router session boost queue where a freed slot could be given to a waiting request before the grace period ended.

Signed-off-by: Abhayanth K <abhayanth2006@gmail.com>
Copilot AI balanced review requested due to automatic review settings November 6, 2026 13:39
@volcano-sh-bot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign hzxuzhonghu 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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@Abhayanthk

Copy link
Copy Markdown
Contributor Author

/cc @YaoZengzeng @kube-gopher @LiZhenCheng9527
PTAL when you have time.

This branch has not been deployed

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

Projects

Status: Accepted

Development

Successfully merging this pull request may close these issues.

3 participants