Skip to content

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

Merged
JmPotato merged 5 commits intotikv:release-8.5-20260323-v8.5.5from
ti-chi-bot:cherry-pick-10252-to-release-8.5-20260323-v8.5.5
Mar 30, 2026
Merged

resourcegroup: replace blind sleep with signal-aware wait in acquireTokens (#10252)#10505
JmPotato merged 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.

close tikv#10251

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@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.

This reverts commit c6ce272.

Signed-off-by: JmPotato <github@ipotato.me>
…okens

(cherry picked from commit 961bd132b28f6345af0df288a33741f9c7dcfd2e)
Signed-off-by: JmPotato <github@ipotato.me>
@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
Signed-off-by: JmPotato <github@ipotato.me>
Signed-off-by: JmPotato <github@ipotato.me>
@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).
⚠️ Report is 1 commits behind head on release-8.5-20260323-v8.5.5.

❌ Your patch status 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.

@ti-chi-bot ti-chi-bot Bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Mar 30, 2026
@ti-chi-bot ti-chi-bot Bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Mar 30, 2026
@ti-chi-bot
Copy link
Copy Markdown
Contributor

ti-chi-bot Bot commented Mar 30, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: okJiang, rleungx

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

The pull request process is described 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
Copy link
Copy Markdown
Contributor

ti-chi-bot Bot commented Mar 30, 2026

[LGTM Timeline notifier]

Timeline:

  • 2026-03-30 02:17:38.103683297 +0000 UTC m=+145063.309043354: ☑️ agreed by rleungx.
  • 2026-03-30 10:19:48.535270543 +0000 UTC m=+173993.740630590: ☑️ agreed by okJiang.

@JmPotato JmPotato merged commit ebf9af0 into tikv:release-8.5-20260323-v8.5.5 Mar 30, 2026
28 of 45 checks passed
@JmPotato JmPotato deleted the cherry-pick-10252-to-release-8.5-20260323-v8.5.5 branch March 30, 2026 11:00
JmPotato pushed a commit to JmPotato/tidb that referenced this pull request Mar 30, 2026
Update github.com/tikv/pd/client to v0.0.0-20260330105957-ebf9af006aac
which includes tikv/pd#10505 (cherry-pick of pingcap#10252: replace blind sleep
with signal-aware wait in acquireTokens).

Signed-off-by: Alice <alice@slock.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved 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. lgtm 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.

4 participants