Skip to content

balance, proxy: fix TiDB CPU imbalance when balance.policy="resource" (#1173)#1174

Open
ti-chi-bot wants to merge 2 commits into
pingcap:release-1.3from
ti-chi-bot:cherry-pick-1173-to-release-1.3
Open

balance, proxy: fix TiDB CPU imbalance when balance.policy="resource" (#1173)#1174
ti-chi-bot wants to merge 2 commits into
pingcap:release-1.3from
ti-chi-bot:cherry-pick-1173-to-release-1.3

Conversation

@ti-chi-bot

Copy link
Copy Markdown
Member

This is an automated cherry-pick of #1173

What problem does this PR solve?

Issue Number: close #1172

Problem Summary:

  • When a connection is closing and migrating concurrently, the connection may be leaked, leading to wrong CPU scores.
  • Data race in ScoreBasedRoute.updateGroups().
  • Other minor concurrency bugs.

What is changed and how it works:

  • Add physicalOwner and scoreOwner to the backendWrapper so that it can always find the right backend.
  • Remove redirectingBackendID because it's unnecessary now.
  • Fix the non-atomic access of BackendConnManager.redirectResCh.
  • Fix the redirect result is incorrectly set in BackendConnManager.tryRedirect.
  • Other minor fixes.

Check List

Tests

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

Notable changes

  • Has configuration change
  • Has HTTP API interfaces change
  • Has tiproxyctl change
  • Other user behavior changes

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot

ti-chi-bot Bot commented Jun 15, 2026

Copy link
Copy Markdown

This cherry pick PR is for a release branch and has not yet been approved by triage owners.
Adding the do-not-merge/cherry-pick-not-approved label.

To merge this cherry pick:

  1. It must be LGTMed and approved by the reviewers firstly.
  2. For pull requests to TiDB-x branches, it must have no failed tests.
  3. AFTER it has lgtm and approved labels, please wait for the cherry-pick merging approval from triage owners.
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 kubernetes-sigs/prow repository.

@ti-chi-bot

Copy link
Copy Markdown
Member Author

@djshow832 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

ti-chi-bot Bot commented Jun 15, 2026

Copy link
Copy Markdown

[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 djshow832. 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/XL and removed size/XXL labels Jun 15, 2026
@djshow832 djshow832 marked this pull request as ready for review June 15, 2026 12:02
@ti-chi-bot ti-chi-bot Bot requested review from bb7133 and xhebox June 15, 2026 12:02
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 71.42857% with 18 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (release-1.3@1fc4a46). Learn more about missing BASE report.

Files with missing lines Patch % Lines
pkg/balance/router/router_score.go 70.58% 7 Missing and 3 partials ⚠️
pkg/proxy/backend/backend_conn_mgr.go 63.15% 6 Missing and 1 partial ⚠️
pkg/balance/router/router_static.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff               @@
##             release-1.3    #1174   +/-   ##
==============================================
  Coverage               ?   65.67%           
==============================================
  Files                  ?      125           
  Lines                  ?    12342           
  Branches               ?        0           
==============================================
  Hits                   ?     8106           
  Misses                 ?     3695           
  Partials               ?      541           
Flag Coverage Δ
unit 65.67% <71.42%> (?)

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

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants