Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

infoschema: fix exec_count of prepared statements in statement summary (#17064) #17086

Merged
merged 5 commits into from
May 12, 2020

Conversation

sre-bot
Copy link
Contributor

@sre-bot sre-bot commented May 11, 2020

cherry-pick #17064 to release-4.0


What problem does this PR solve?

Problem Summary:

mysql> prepare stmt from 'select ?';
Query OK, 0 rows affected (0.00 sec)

mysql> set @number=1;
Query OK, 0 rows affected (0.00 sec)

mysql> execute stmt using @number;
+------+
| ?    |
+------+
| 1    |
+------+
1 row in set (0.00 sec)

mysql> select exec_count from information_schema.statements_summary where digest_text='select ?';
+------------+
| exec_count |
+------------+
|          2 |
+------------+
1 row in set (0.00 sec)

The final result should be 1, not 2.

Note: In events_statements_summary_by_digest in MySQL, PREPARE and EXECUTE statements are recorded separately, and digest_text stays what they were.
But we record the SQL filled with parameters (referred as final SQL below), because:

  1. Slow queries use the digest of the final SQL, and Dashboard use the digest to jump from statements to slow query. So the digests should be the same.
  2. It's easier to filter statements by stmt_type field.
  3. query_sample_text can be the final SQL, which can be used to reproduce the problem more easily.

What is changed and how it works?

What's Changed:
Ignore PREPARE statements in statement summary.

Related changes

  • Need to cherry-pick to the release branch

Check List

Tests

  • Unit test

Side effects

N/A

Release note

  • fix exec_count of prepared statements in statement summary.

@sre-bot sre-bot requested a review from a team as a code owner May 11, 2020 06:56
@sre-bot
Copy link
Contributor Author

sre-bot commented May 11, 2020

/run-all-tests

Copy link
Contributor

@Deardrops Deardrops left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@AilinKid AilinKid left a comment

Choose a reason for hiding this comment

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

LGTM

@AilinKid
Copy link
Contributor

/run-all-tests

@djshow832
Copy link
Contributor

/run-all-tests

@djshow832
Copy link
Contributor

UT failed due to #16870

@djshow832
Copy link
Contributor

/run-all-tests

@qw4990 qw4990 removed their request for review May 12, 2020 09:43
@bb7133 bb7133 merged commit 22076bc into pingcap:release-4.0 May 12, 2020
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.

5 participants