Skip to content

resourcegroup: replace blind sleep with signal-aware wait in acquireTokens (#10252)#10505

Open
ti-chi-bot wants to merge 5 commits intotikv:release-8.5-20260323-v8.5.5from
ti-chi-bot:cherry-pick-10252-to-release-8.5-20260323-v8.5.5
Open

resourcegroup: replace blind sleep with signal-aware wait in acquireTokens (#10252)#10505
ti-chi-bot wants to merge 5 commits intotikv:release-8.5-20260323-v8.5.5from
ti-chi-bot:cherry-pick-10252-to-release-8.5-20260323-v8.5.5

Conversation

@ti-chi-bot
Copy link
Copy Markdown
Member

This is an automated cherry-pick of #10252

What problem does this PR solve?

Issue Number: close #10251.

What is changed and how does it work?

Add a close-and-recreate channel on the `Limiter` that is closed on every `Reconfigure()` call.
The retry loop in `acquireTokens` now selects on this channel instead of blind-sleeping,
waking up immediately when new tokens arrive. The timer serves as a fallback to preserve original
behavior when no `Reconfigure` occurs.

Check List

Tests

  • Unit test
  • Integration test

Release note

None.

Summary by CodeRabbit

  • Bug Fixes

    • Token acquisition retry now uses an interruptible wait so reconfiguration cancels unnecessary delays, improving responsiveness during limiter changes.
  • New Features

    • Limiter now signals reconfiguration to promptly wake waiting operations.
  • Tests

    • Added coverage for signal-aware wakeups, timer fallback behavior, and waking multiple waiters during reconfiguration.

@ti-chi-bot ti-chi-bot added dco-signoff: yes Indicates the PR's author has signed the dco. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. type/cherry-pick-for-release-8.5-20260323-v8.5.5 labels Mar 27, 2026
@ti-chi-bot
Copy link
Copy Markdown
Member Author

@JmPotato This PR has conflicts, I have hold it.
Please resolve them or ask others to resolve them, then comment /unhold to remove the hold label.

@ti-chi-bot
Copy link
Copy Markdown
Contributor

ti-chi-bot bot commented Mar 27, 2026

@ti-chi-bot: ## If you want to know how to resolve it, please read the guide in TiDB Dev Guide.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@ti-chi-bot ti-chi-bot bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 27, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 27, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8682b34c-3425-44c8-aa8f-b76318733dd3

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

…okens

(cherry picked from commit 961bd132b28f6345af0df288a33741f9c7dcfd2e)
Signed-off-by: JmPotato <[email protected]>
@ti-chi-bot
Copy link
Copy Markdown
Contributor

ti-chi-bot bot commented Mar 27, 2026

[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 ask for approval from jmpotato. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

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

@ti-chi-bot ti-chi-bot bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Mar 27, 2026
@JmPotato
Copy link
Copy Markdown
Member

/retest

1 similar comment
@JmPotato
Copy link
Copy Markdown
Member

/retest

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 27, 2026

Codecov Report

❌ Patch coverage is 59.37500% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.85%. Comparing base (9c9a8c8) to head (79eb1f1).

❌ Your patch check has failed because the patch coverage (59.37%) is below the target coverage (74.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@                       Coverage Diff                       @@
##           release-8.5-20260323-v8.5.5   #10505      +/-   ##
===============================================================
- Coverage                        77.98%   77.85%   -0.14%     
===============================================================
  Files                              482      482              
  Lines                            65391    65419      +28     
===============================================================
- Hits                             50997    50932      -65     
- Misses                           10665    10747      +82     
- Partials                          3729     3740      +11     
Flag Coverage Δ
unittests 77.85% <59.37%> (-0.14%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Labels

dco-signoff: yes Indicates the PR's author has signed the dco. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. type/cherry-pick-for-release-8.5-20260323-v8.5.5

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants