Skip to content

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

Merged
ti-chi-bot[bot] merged 3 commits into
pingcap:release-nextgen-202603from
ti-chi-bot:cherry-pick-1173-to-release-nextgen-202603
Jun 15, 2026
Merged

balance, proxy: fix TiDB CPU imbalance when balance.policy="resource" (#1173)#1175
ti-chi-bot[bot] merged 3 commits into
pingcap:release-nextgen-202603from
ti-chi-bot:cherry-pick-1173-to-release-nextgen-202603

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

@ti-chi-bot ti-chi-bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. type/cherry-pick-for-release-nextgen-202603 labels Jun 15, 2026
@ti-chi-bot
ti-chi-bot Bot requested review from YangKeao and bb7133 June 15, 2026 05:54
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.30864% with 20 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (release-nextgen-202603@20ece63). Learn more about missing BASE report.

Files with missing lines Patch % Lines
pkg/balance/router/group.go 74.35% 7 Missing and 3 partials ⚠️
pkg/proxy/backend/backend_conn_mgr.go 55.00% 8 Missing and 1 partial ⚠️
pkg/balance/router/router_static.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@                    Coverage Diff                    @@
##             release-nextgen-202603    #1175   +/-   ##
=========================================================
  Coverage                          ?   67.55%           
=========================================================
  Files                             ?      149           
  Lines                             ?    16208           
  Branches                          ?        0           
=========================================================
  Hits                              ?    10949           
  Misses                            ?     4523           
  Partials                          ?      736           
Flag Coverage Δ
unit 67.55% <75.30%> (?)

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.

@ti-chi-bot

ti-chi-bot Bot commented Jun 15, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: djshow832

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 ti-chi-bot Bot added the lgtm label Jun 15, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jun 15, 2026

Copy link
Copy Markdown

[LGTM Timeline notifier]

Timeline:

  • 2026-06-15 06:49:23.056589771 +0000 UTC m=+1374664.126907161: ☑️ agreed by djshow832.

@ti-chi-bot ti-chi-bot Bot added the approved label Jun 15, 2026
@ti-chi-bot
ti-chi-bot Bot merged commit 8ad2a00 into pingcap:release-nextgen-202603 Jun 15, 2026
6 checks passed
@djshow832
djshow832 deleted the cherry-pick-1173-to-release-nextgen-202603 branch June 15, 2026 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved lgtm size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. type/cherry-pick-for-release-nextgen-202603

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants