Skip to content

runner: set capacity to Task channel #9226

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 24, 2025
Merged

Conversation

okJiang
Copy link
Member

@okJiang okJiang commented Apr 21, 2025

What problem does this PR solve?

Issue Number: Close #9222

What is changed and how does it work?

If the program processPendingTask and handle <-ticker.C in the same time

case cr.taskChan <- task:

case <-ticker.C:

, the task may be skipped due to taskChan block.

pd/pkg/ratelimit/runner.go

Lines 170 to 175 in f86063f

select {
case cr.taskChan <- task:
cr.pendingTasks = cr.pendingTasks[1:]
cr.pendingTaskCount[task.name]--
delete(cr.existTasks, taskID{id: task.id, name: task.name})
default:

So, we can give a capacity to the task channel to avoid this situation.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)

image

  • No code

Release note

None.

Signed-off-by: okJiang <[email protected]>
@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. dco-signoff: yes Indicates the PR's author has signed the dco. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Apr 21, 2025
@okJiang
Copy link
Member Author

okJiang commented Apr 21, 2025

/retest

Signed-off-by: okJiang <[email protected]>
@ti-chi-bot ti-chi-bot bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Apr 21, 2025
Copy link

codecov bot commented Apr 21, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 76.12%. Comparing base (0ae92cd) to head (cf13705).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9226      +/-   ##
==========================================
+ Coverage   76.05%   76.12%   +0.06%     
==========================================
  Files         470      470              
  Lines       73028    73028              
==========================================
+ Hits        55543    55589      +46     
+ Misses      14039    14016      -23     
+ Partials     3446     3423      -23     
Flag Coverage Δ
unittests 76.12% <100.00%> (+0.06%) ⬆️

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.

@@ -82,7 +82,7 @@ func TestConcurrentRunner(t *testing.T) {
for i := 1; i < 11; i++ {
regionID := uint64(i)
if i == 10 {
regionID = 4
regionID = 6
Copy link
Contributor

Choose a reason for hiding this comment

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

why change it?

Copy link
Member Author

@okJiang okJiang Apr 22, 2025

Choose a reason for hiding this comment

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

To pass this ut. Capacity changed the pendingTask index. To ensure the task is not consumed as much as possible, I have increased the region ID a bit more.

@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Apr 22, 2025
@nolouch
Copy link
Contributor

nolouch commented Apr 23, 2025

I think the task will be handled well next time, even if you have the capacity, the same problem will still exist.

@ti-chi-bot ti-chi-bot bot added the lgtm label Apr 23, 2025
Copy link
Contributor

ti-chi-bot bot commented Apr 23, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lhy1024, nolouch

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

The pull request process is described here

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 removed the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Apr 23, 2025
Copy link
Contributor

ti-chi-bot bot commented Apr 23, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-04-22 10:11:32.155905491 +0000 UTC m=+350435.967695874: ☑️ agreed by lhy1024.
  • 2025-04-23 06:16:08.326534174 +0000 UTC m=+422712.138324554: ☑️ agreed by nolouch.

@okJiang
Copy link
Member Author

okJiang commented Apr 23, 2025

/retest

@ti-chi-bot ti-chi-bot bot merged commit 0c6154d into tikv:master Apr 24, 2025
25 checks passed
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. lgtm release-note-none Denotes a PR that doesn't merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pending task may be kept forever when there is no task coming
3 participants