Skip to content

Conversation

@ti-chi-bot
Copy link
Member

@ti-chi-bot ti-chi-bot commented Sep 30, 2025

This is an automated cherry-pick of #63409
cherry-pick of #60296

What problem does this PR solve?

Issue Number: close #63407

Problem Summary:

What changed and how does it work?

Currently, some customers have created a large number of bindings. However, it is difficult to determine whether these bindings are still in use. The sheer volume of bindings also puts pressure on TiDB. Therefore, we need a way to identify and mark the bindings that are not in use.

Check List

Tests

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

start a tidb with master which is started by script. Tikv and PD is started by tiup playground nightly --mode tikv-slim.

+----------------------------------+----------------------------------+------------+---------+-------------------------+-------------------------+---------+-----------+---------+------------+-------------+
| original_sql                     | bind_sql                         | default_db | status  | create_time             | update_time             | charset | collation | source  | sql_digest | plan_digest |
+----------------------------------+----------------------------------+------------+---------+-------------------------+-------------------------+---------+-----------+---------+------------+-------------+
| builtin_pseudo_sql_for_bind_lock | builtin_pseudo_sql_for_bind_lock | mysql      | builtin | 0000-00-00 00:00:00.000 | 0000-00-00 00:00:00.000 |         |           | builtin | <null>     | <null>      |
+----------------------------------+----------------------------------+------------+---------+-------------------------+-------------------------+---------+-----------+---------+------------+-------------+

kill this TiDB and start changed tidb verson.

+----------------------------------+----------------------------------+------------+---------+-------------------------+-------------------------+---------+-----------+---------+------------+-------------+----------------+
| original_sql                     | bind_sql                         | default_db | status  | create_time             | update_time             | charset | collation | source  | sql_digest | plan_digest | last_used_time |
+----------------------------------+----------------------------------+------------+---------+-------------------------+-------------------------+---------+-----------+---------+------------+-------------+----------------+
| builtin_pseudo_sql_for_bind_lock | builtin_pseudo_sql_for_bind_lock | mysql      | builtin | 0000-00-00 00:00:00.000 | 0000-00-00 00:00:00.000 |         |           | builtin | <null>     | <null>      | <null>         |
+----------------------------------+----------------------------------+------------+---------+-------------------------+-------------------------+---------+-----------+---------+------------+-------------+----------------+

BTW

The code in this area still differs from that on the master branch, which may lead to performance issues. The difference lies in the fact that version 8.5 requires an additional memory setting operation. However, from what we can see on the profiler

image

According to the flame graph, this part only accounts for 0.1% of the total query cost. Therefore, one additional set operation is roughly equivalent to the cost of one get operation, making the overall impact very limited.

I add a benchmark for binding. The overhead here is less than 3%. The overhead of TiKV has not been taken into account here. This part only ran the EXPLAIN command and did not execute the query.

before

BenchmarkFuzzyBindingBasic-8   	    1143	    903480 ns/op	 1178957 B/op	   15274 allocs/op

after

BenchmarkFuzzyBindingBasic-8   	    1318	    932915 ns/op	 1189334 B/op	   15624 allocs/op
  • No need to test
    • I checked and no code files have been changed.

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

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

None

@ti-chi-bot ti-chi-bot added 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. sig/planner SIG: Planner size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. type/cherry-pick-for-release-8.5 This PR is cherry-picked to release-8.5 from a source PR. labels Sep 30, 2025
@ti-chi-bot
Copy link

ti-chi-bot bot commented Sep 30, 2025

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 approved by the approvers firstly.
  2. AFTER it has been approved by approvers, please wait for the cherry-pick merging approval from triage owners.

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
Member Author

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

ti-chi-bot bot commented Sep 30, 2025

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

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/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Sep 30, 2025
@ti-chi-bot ti-chi-bot bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Oct 10, 2025
@codecov
Copy link

codecov bot commented Oct 10, 2025

Codecov Report

❌ Patch coverage is 78.32512% with 44 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (release-8.5@e9af1b4). Learn more about missing BASE report.

Additional details and impacted files
@@               Coverage Diff                @@
##             release-8.5     #63824   +/-   ##
================================================
  Coverage               ?   77.2261%           
================================================
  Files                  ?       1654           
  Lines                  ?     455175           
  Branches               ?          0           
================================================
  Hits                   ?     351514           
  Misses                 ?      82186           
  Partials               ?      21475           
Flag Coverage Δ
integration 50.4380% <54.6798%> (?)
unit 72.7512% <71.9211%> (?)

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

Components Coverage Δ
dumpling 52.9278% <0.0000%> (?)
parser ∅ <0.0000%> (?)
br 63.3626% <0.0000%> (?)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ti-chi-bot ti-chi-bot bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Oct 14, 2025
@hawkingrei
Copy link
Member

/retest

1 similar comment
@hawkingrei
Copy link
Member

/retest

@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Oct 15, 2025
@hawkingrei
Copy link
Member

/retest

Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
@hawkingrei hawkingrei force-pushed the cherry-pick-63409-to-release-8.5 branch from 3092139 to e2016e7 Compare October 16, 2025 04:41
@hawkingrei
Copy link
Member

/unhold

@ti-chi-bot ti-chi-bot bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 21, 2025
@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Oct 21, 2025
@ti-chi-bot
Copy link

ti-chi-bot bot commented Oct 21, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-10-15 08:34:53.599137199 +0000 UTC m=+255999.676389759: ☑️ agreed by qw4990.
  • 2025-10-21 02:41:08.780548785 +0000 UTC m=+753174.857801345: ☑️ agreed by you06.

@D3Hunter
Copy link
Contributor

/approve

Signed-off-by: Weizhen Wang <[email protected]>
@hawkingrei hawkingrei requested a review from D3Hunter October 21, 2025 03:31
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
Copy link

@yudongusa yudongusa left a comment

Choose a reason for hiding this comment

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

Please open doc PR on this

@ti-chi-bot ti-chi-bot bot added the approved label Oct 21, 2025
@hawkingrei
Copy link
Member

/retest

@hawkingrei
Copy link
Member

Please open doc PR on this

Please create a doc PR here.

pingcap/docs#21948
pingcap/docs#21946

Copy link
Contributor

@BornChanger BornChanger left a comment

Choose a reason for hiding this comment

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

br side lgtm.

@ti-chi-bot
Copy link

ti-chi-bot bot commented Oct 22, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: BornChanger, D3Hunter, hawkingrei, Leavrth, qw4990, you06, yudongusa

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

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

Labels

approved do-not-merge/cherry-pick-not-approved lgtm release-note-none Denotes a PR that doesn't merit a release note. sig/planner SIG: Planner size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. type/cherry-pick-for-release-8.5 This PR is cherry-picked to release-8.5 from a source PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants