Skip to content

Conversation

@mjonss
Copy link
Contributor

@mjonss mjonss commented Sep 23, 2025

What problem does this PR solve?

Issue Number: close #63671

Problem Summary:
For queries longer than 4096 characters, it will be truncated in the statements_summary tables, resulting in CREATE GLOBAL BINDING FROM HISTORY USING PLAN DIGEST '' does not work, and it gives a cryptic error from the parser.

What changed and how does it work?

Increased the default from 4k to 32k and updated the error message, to point to tidb_stmt_summary_max_sql_length global system variable, controlling the length.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • 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
    • Only if actually using such long queries.
  • 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.

Changed default `tidb_stmt_summary_max_sql_length` from 4096 to 32768 to not truncate medium/large queries in the statements_summary tables.

@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-triage-completed release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. sig/planner SIG: Planner labels Sep 23, 2025
@tiprow
Copy link

tiprow bot commented Sep 23, 2025

Hi @mjonss. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

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.

@mjonss
Copy link
Contributor Author

mjonss commented Sep 23, 2025

/check-issue-triage-complete

@hawkingrei
Copy link
Member

/retest

@hawkingrei hawkingrei self-requested a review September 23, 2025 11:41
@hawkingrei
Copy link
Member

@mjonss Please fix the CI.

@hawkingrei
Copy link
Member

/retest

@codecov
Copy link

codecov bot commented Sep 25, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.9752%. Comparing base (8840daf) to head (a298d25).
⚠️ Report is 11 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #63694        +/-   ##
================================================
+ Coverage   72.7311%   73.9752%   +1.2441%     
================================================
  Files          1848       1849         +1     
  Lines        498587     505327      +6740     
================================================
+ Hits         362628     373817     +11189     
+ Misses       113927     109642      -4285     
+ Partials      22032      21868       -164     
Flag Coverage Δ
integration 42.9301% <87.5000%> (?)
unit 73.1597% <50.0000%> (+0.8869%) ⬆️

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

Components Coverage Δ
dumpling 52.8700% <ø> (ø)
parser ∅ <ø> (∅)
br 46.4741% <ø> (+0.0506%) ⬆️
🚀 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.

@mjonss
Copy link
Contributor Author

mjonss commented Sep 29, 2025

/retest

@tiprow
Copy link

tiprow bot commented Sep 29, 2025

@mjonss: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

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.

@mjonss mjonss added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 30, 2025
Copy link
Contributor

@henrybw henrybw left a comment

Choose a reason for hiding this comment

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

I think this should be fine: I don't think it will add significantly more memory pressure overall. (And if it does turn out to be a problem, we can turn down the default later.)

Comment on lines +954 to +955
return nil, errors.NewNoStackErrorf("binding failed: SQL query is truncated due to tidb_stmt_summary_max_sql_length limit. "+
"Please increase tidb_stmt_summary_max_sql_length. Plan Digest: %v", planDigest)
Copy link
Contributor

Choose a reason for hiding this comment

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

I would consider using the vardef.TiDBStmtSummaryMaxSQLLength constant instead of hardcoding tidb_stmt_summary_max_sql_length in the error message, but I don't consider it a blocking issue.

@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Oct 3, 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 3, 2025
@ti-chi-bot
Copy link

ti-chi-bot bot commented Oct 3, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-10-03 03:03:22.80602704 +0000 UTC m=+399383.062758440: ☑️ agreed by henrybw.
  • 2025-10-03 03:21:15.421273161 +0000 UTC m=+400455.678004580: ☑️ agreed by wddevries.

@terry1purcell
Copy link
Contributor

/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 3, 2025
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 also open a document PR

@ti-chi-bot
Copy link

ti-chi-bot bot commented Oct 3, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: henrybw, terry1purcell, wddevries, 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

@ti-chi-bot ti-chi-bot bot added the approved label Oct 3, 2025
@ti-chi-bot ti-chi-bot bot merged commit 2b2792b into pingcap:master Oct 3, 2025
29 checks passed
@mjonss mjonss deleted the long-query-bind-from-history branch October 3, 2025 13:45
yibin87 pushed a commit to yibin87/tidb that referenced this pull request Oct 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved lgtm release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/planner SIG: Planner size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CREATE GLOBAL BINDING FROM HISTORY USING PLAN DIGEST fails on long queries

6 participants