Skip to content

Conversation

qw4990
Copy link
Contributor

@qw4990 qw4990 commented Mar 26, 2025

What problem does this PR solve?

Issue Number: ref #60148

Problem Summary: planner: calculate plan_digest in place when fetching plan exec info from stmt_stats in SHOW PLAN FOR <SQL>

What changed and how does it work?

Due to some historical reason, binding.plan_digest might be empty, which prevents us from joining mysql.bind_info and stmt_stats to get bindings' corresponding plan execution info.

For example, if a binding is created manually like create global binding using select ..., then its plan_digest is empty by default.

This PR calculates plan_digest for bindings in place when trying to fetch exec info for a binding. All logic is behind getBindingPlanDigest.

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
  • 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 bot added release-note-none Denotes a PR that doesn't merit a release note. sig/planner SIG: Planner size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 26, 2025
@qw4990 qw4990 requested a review from time-and-fate March 26, 2025 09:36
Copy link

tiprow bot commented Mar 26, 2025

Hi @qw4990. 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.

Copy link

codecov bot commented Mar 26, 2025

Codecov Report

Attention: Patch coverage is 78.46154% with 14 lines in your changes missing coverage. Please review.

Project coverage is 75.0402%. Comparing base (7c0c2b1) to head (bdb6a64).
Report is 6 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #60273        +/-   ##
================================================
+ Coverage   73.1221%   75.0402%   +1.9180%     
================================================
  Files          1710       1756        +46     
  Lines        472557     482549      +9992     
================================================
+ Hits         345544     362106     +16562     
+ Misses       105730      97765      -7965     
- Partials      21283      22678      +1395     
Flag Coverage Δ
integration 49.0266% <1.5384%> (?)
unit 72.4895% <78.4615%> (+0.1600%) ⬆️

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

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

@qw4990
Copy link
Contributor Author

qw4990 commented Mar 26, 2025

/test unit-test

Copy link

tiprow bot commented Mar 26, 2025

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

In response to this:

/test unit-test

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.

@hawkingrei
Copy link
Member

/test all

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.

Seems fine to me.

Comment on lines 102 to 107
if planDigest == "" {
_ = callWithSCtx(ba.sPool, false, func(sctx sessionctx.Context) error {
planDigest = getBindingPlanDigest(sctx, binding.Db, binding.BindSQL)
return nil
})
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Since generating a new plan digest seems like an expensive operation (invoking the planner and optimizing the plan), maybe we should log an info message when we do this? Just a suggestion, though: I'm fine with not logging if you think that makes more sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it, but no logging seems OK since the generation operation is a in-memory operation, which shouldn't take a long time, and SHOW PLAN FOR <SQL> should be a low-frequently operation, so it should be OK here without any logging.

Copy link

ti-chi-bot bot commented Mar 27, 2025

@henrybw: adding LGTM is restricted to approvers and reviewers in OWNERS files.

In response to this:

Seems fine to me.

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

ti-chi-bot bot commented Mar 27, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-03-27 05:57:23.388864265 +0000 UTC m=+1112737.073100360: ☑️ agreed by time-and-fate.
  • 2025-03-27 06:18:57.492093009 +0000 UTC m=+1114031.176329105: ☑️ agreed by hawkingrei.

Copy link

ti-chi-bot bot commented Mar 27, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hawkingrei, henrybw, tangenta, time-and-fate

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 Mar 27, 2025
@hawkingrei
Copy link
Member

/retest

@qw4990
Copy link
Contributor Author

qw4990 commented Mar 28, 2025

/test unit-test

Copy link

tiprow bot commented Mar 28, 2025

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

In response to this:

/test unit-test

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.

@qw4990
Copy link
Contributor Author

qw4990 commented Mar 28, 2025

/test unit-test

Copy link

tiprow bot commented Mar 28, 2025

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

In response to this:

/test unit-test

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.

@qw4990
Copy link
Contributor Author

qw4990 commented Mar 28, 2025

/test mysql-test

Copy link

tiprow bot commented Mar 28, 2025

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

In response to this:

/test mysql-test

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.

@qw4990
Copy link
Contributor Author

qw4990 commented Mar 28, 2025

/test check-dev2

Copy link

tiprow bot commented Mar 28, 2025

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

In response to this:

/test check-dev2

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.

@qw4990
Copy link
Contributor Author

qw4990 commented Mar 29, 2025

/retest

Copy link

tiprow bot commented Mar 29, 2025

@qw4990: 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.

@qw4990
Copy link
Contributor Author

qw4990 commented Mar 29, 2025

/ok-to-test

@qw4990
Copy link
Contributor Author

qw4990 commented Mar 29, 2025

/retest

Copy link

tiprow bot commented Mar 29, 2025

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

In response to this:

/ok-to-test

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.

Copy link

tiprow bot commented Mar 29, 2025

@qw4990: 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.

@qw4990
Copy link
Contributor Author

qw4990 commented Mar 29, 2025

/test check_dev_2

Copy link

tiprow bot commented Mar 29, 2025

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

In response to this:

/test check_dev_2

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.

@terry1purcell
Copy link
Contributor

/ok-to-test

Copy link

tiprow bot commented Mar 29, 2025

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

In response to this:

/ok-to-test

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.

@hawkingrei
Copy link
Member

/ok-to-test

@hawkingrei
Copy link
Member

/retest

1 similar comment
@qw4990
Copy link
Contributor Author

qw4990 commented Mar 31, 2025

/retest

Copy link

tiprow bot commented Mar 31, 2025

@qw4990: 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.

@qw4990
Copy link
Contributor Author

qw4990 commented Mar 31, 2025

/test check-dev2

Copy link

tiprow bot commented Mar 31, 2025

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

In response to this:

/test check-dev2

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.

@qw4990
Copy link
Contributor Author

qw4990 commented Mar 31, 2025

/test unit-test

Copy link

tiprow bot commented Mar 31, 2025

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

In response to this:

/test unit-test

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 ti-chi-bot bot merged commit 446952c into pingcap:master Mar 31, 2025
26 checks passed
zeminzhou pushed a commit to zeminzhou/tidb that referenced this pull request May 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note-none Denotes a PR that doesn't merit a release note. sig/planner SIG: Planner size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants