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
*: add plan hint to slow log files when redaction is enabled #42170
Conversation
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
Skipping CI for Draft Pull Request. |
/test all |
/test unit-test |
1 similar comment
/test unit-test |
executor/slow_query_test.go
Outdated
@@ -186,7 +186,7 @@ select * from t;` | |||
`0,0,0,0,0,0,0,0,0,0,0,0,,0,0,0,0,0,0,0.38,0.021,0,0,0,1,637,0,10,10,10,10,100,,,1,42a1c8aae6f133e934d4bf0147491709a8812ea05ff8819ec522780fe657b772,t1:1,t2:2,` + | |||
`0.1,0.2,0.03,127.0.0.1:20160,0.05,0.6,0.8,0.0.0.0:20160,70724,65536,0,0,0,0,0,,` + | |||
`Cop_backoff_regionMiss_total_times: 200 Cop_backoff_regionMiss_total_time: 0.2 Cop_backoff_regionMiss_max_time: 0.2 Cop_backoff_regionMiss_max_addr: 127.0.0.1 Cop_backoff_regionMiss_avg_time: 0.2 Cop_backoff_regionMiss_p90_time: 0.2 Cop_backoff_rpcPD_total_times: 200 Cop_backoff_rpcPD_total_time: 0.2 Cop_backoff_rpcPD_max_time: 0.2 Cop_backoff_rpcPD_max_addr: 127.0.0.1 Cop_backoff_rpcPD_avg_time: 0.2 Cop_backoff_rpcPD_p90_time: 0.2 Cop_backoff_rpcTiKV_total_times: 200 Cop_backoff_rpcTiKV_total_time: 0.2 Cop_backoff_rpcTiKV_max_time: 0.2 Cop_backoff_rpcTiKV_max_addr: 127.0.0.1 Cop_backoff_rpcTiKV_avg_time: 0.2 Cop_backoff_rpcTiKV_p90_time: 0.2,` + | |||
`0,0,1,0,1,1,0,,60e9378c746d9a2be1c791047e008967cf252eb6de9167ad3aa6098fa2d523f4,` + | |||
`0,0,1,0,1,1,0,,60e9378c746d9a2be1c791047e008967cf252eb6de9167ad3aa6098fa2d523f4,,` + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you please add a test with hint?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know how to generate a real slow log in unit test framework. Seems all the tests of slow logs are parsing/reading the hand-writting files. The useful test is to check how the hint to be generated.
/rebuild |
/hold |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/test all |
/unhold |
@@ -520,7 +528,7 @@ func startWithSlash(s *Scanner) (tok int, pos Pos, lit string) { | |||
|
|||
case '+': // '/*+' optimizer hints | |||
// See https://dev.mysql.com/doc/refman/5.7/en/optimizer-hints.html | |||
if _, ok := hintedTokens[s.lastKeyword]; ok { | |||
if _, ok := hintedTokens[s.lastKeyword]; ok || s.keepHint { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this change needed? The check is to mimic MySQL's behavior that a hint must follow certain keywords (SELECT, INSERT, etc.); I don't think normalization will move the hint elsewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When normalizing SQL, the value of lastKeyword will always be 0, resulting in the omission of all hints.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am unable to find an appropriate method of handling it.
/merge |
This pull request has been accepted and is ready to merge. Commit hash: 49ff26235bd29ea91efefe8b061fb9024cfcef47
|
/retest |
7 similar comments
/retest |
/retest |
/retest |
/retest |
/retest |
/retest |
/retest |
/test all |
/retest |
Signed-off-by: Jack Yu <jackysp@gmail.com>
Signed-off-by: Jack Yu <jackysp@gmail.com>
49ff262
to
6007b0e
Compare
/merge |
This pull request has been accepted and is ready to merge. Commit hash: 6007b0e
|
What problem does this PR solve?
Issue Number: close #42169
Problem Summary:
Plan hint will be redacted when enabling the log redaction in slow log files.
What is changed and how it works?
Add the hint as an item to the slow log files.
An example looks like this:
Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.