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

*: add global variable tidb_slow_log_masking to control masking slow log query #17637

Merged
merged 8 commits into from
Jun 5, 2020

Conversation

crazycs520
Copy link
Contributor

@crazycs520 crazycs520 commented Jun 3, 2020

Signed-off-by: crazycs [email protected]

What problem does this PR solve?

Issue Number: close #17463

This PR adds global variable tidb_slow_log_masking to control masking slow log query.

Such as below:

  1. Enable the tidb_slow_log_masking first.
 set @@global.tidb_slow_log_masking=1;
  1. Then, when TiDB record the slow log, it will masking the user data of SQL,
    just like SQL normalize, such as below:
# Time: 2020-06-03T18:28:39.886171+08:00
...
...
...
select count ( ? ) , sum ( query_time ) , digest from information_schema . cluster_slow_query where time >= ? and time < ? group by digest order by sum ( query_time ) desc;

The original SQL is:

select count(*), sum(query_time), digest from information_schema.CLUSTER_SLOW_QUERY where time >= '2020-03-05 20:55:00' and time < '2020-06-05 20:57:00' group by digest order by sum(query_time) desc;

What is changed and how it works?

Related changes

  • PR to update pingcap/docs/pingcap/docs-cn:

Check List

Tests

  • Unit test
  • Manual test

Side effects

  • No

Release note

  • add global variable tidb_slow_log_masking to control masking slow log query.

@crazycs520 crazycs520 added the type/enhancement The issue or PR belongs to an enhancement. label Jun 3, 2020
@github-actions github-actions bot added the sig/execution SIG execution label Jun 3, 2020
@codecov
Copy link

codecov bot commented Jun 3, 2020

Codecov Report

Merging #17637 into master will not change coverage.
The diff coverage is n/a.

@@             Coverage Diff             @@
##             master     #17637   +/-   ##
===========================================
  Coverage   79.4969%   79.4969%           
===========================================
  Files           524        524           
  Lines        141413     141413           
===========================================
  Hits         112419     112419           
  Misses        19930      19930           
  Partials       9064       9064           

@crazycs520
Copy link
Contributor Author

/run-all-tests

Copy link
Member

@bb7133 bb7133 left a comment

Choose a reason for hiding this comment

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

LGTM

@bb7133 bb7133 added the status/LGT1 Indicates that a PR has LGTM 1. label Jun 4, 2020
Copy link
Member

@wjhuang2016 wjhuang2016 left a comment

Choose a reason for hiding this comment

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

LGTM

@bb7133
Copy link
Member

bb7133 commented Jun 4, 2020

/run-all-tests

@jackysp
Copy link
Member

jackysp commented Jun 4, 2020

/merge

@sre-bot
Copy link
Contributor

sre-bot commented Jun 4, 2020

Sorry @jackysp, you don't have permission to trigger auto merge event on this branch.

@bb7133 bb7133 added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Jun 4, 2020
@bb7133
Copy link
Member

bb7133 commented Jun 4, 2020

/run-unit-test /run-integration-br-test

@AndreMouche
Copy link
Contributor

/merge

@sre-bot
Copy link
Contributor

sre-bot commented Jun 4, 2020

Sorry @AndreMouche, you don't have permission to trigger auto merge event on this branch. You are not a committer for this part

@jackysp jackysp removed the sig/execution SIG execution label Jun 4, 2020
@jackysp
Copy link
Member

jackysp commented Jun 4, 2020

/merge

@sre-bot
Copy link
Contributor

sre-bot commented Jun 4, 2020

Sorry @jackysp, you don't have permission to trigger auto merge event on this branch. You are not a committer for this part

@jackysp
Copy link
Member

jackysp commented Jun 4, 2020

/merge

@sre-bot
Copy link
Contributor

sre-bot commented Jun 4, 2020

Sorry @jackysp, you don't have permission to trigger auto merge event on this branch. You are not a committer for this part

@jackysp jackysp closed this Jun 4, 2020
@jackysp jackysp reopened this Jun 4, 2020
@jackysp
Copy link
Member

jackysp commented Jun 4, 2020

/merge

@sre-bot
Copy link
Contributor

sre-bot commented Jun 4, 2020

Sorry @jackysp, you don't have permission to trigger auto merge event on this branch. You are not a committer for this part

@jackysp jackysp added the sig/transaction SIG:Transaction label Jun 4, 2020
@jackysp
Copy link
Member

jackysp commented Jun 4, 2020

/merge

@sre-bot sre-bot added the status/can-merge Indicates a PR has been approved by a committer. label Jun 4, 2020
@jackysp jackysp removed the sig/transaction SIG:Transaction label Jun 4, 2020
@sre-bot
Copy link
Contributor

sre-bot commented Jun 4, 2020

/run-all-tests

@jackysp jackysp added status/can-merge Indicates a PR has been approved by a committer. and removed status/can-merge Indicates a PR has been approved by a committer. labels Jun 4, 2020
@sre-bot
Copy link
Contributor

sre-bot commented Jun 4, 2020

Sorry @jackysp, you don't have permission to trigger auto merge event on this branch. You are not a committer for this part

@sre-bot
Copy link
Contributor

sre-bot commented Jun 4, 2020

@crazycs520 merge failed.

@AndreMouche
Copy link
Contributor

/merge

@sre-bot
Copy link
Contributor

sre-bot commented Jun 4, 2020

Sorry @AndreMouche, you don't have permission to trigger auto merge event on this branch. You are not a committer for this part

@bb7133
Copy link
Member

bb7133 commented Jun 4, 2020

/run-common-test

@github-actions github-actions bot added the sig/execution SIG execution label Jun 4, 2020
@@ -399,6 +399,9 @@ const (

// TiDBEnableClusteredIndex indicates if clustered index feature is enabled.
TiDBEnableClusteredIndex = "tidb_enable_clustered_index"

// TiDBSlowLogMasking indicates that whether masking the query data when log slow query.
Copy link
Member

Choose a reason for hiding this comment

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

Does it only effective for parameterized queries?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What's your mean of parameterized queries?

Actually the masking SQL is also used to generate the SQL digest.

Copy link
Member

Choose a reason for hiding this comment

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

Oh, I mean prepared statements. For non prepared statements, will they have effect?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, It also works on non-prepared statement.

@bb7133
Copy link
Member

bb7133 commented Jun 4, 2020

/run-all-tests

@crazycs520
Copy link
Contributor Author

/integration-ddl-test

@AndreMouche AndreMouche removed the sig/execution SIG execution label Jun 4, 2020
@github-actions github-actions bot added the sig/execution SIG execution label Jun 4, 2020
@bb7133
Copy link
Member

bb7133 commented Jun 4, 2020

/run-integration-ddl-test

@breezewish
Copy link
Member

What will happen to the parameters appears in the plan? This can also be a source of leaking data.

@breezewish
Copy link
Member

I also opened a related issue for the statement part, which will encounter similar problems and needs some design: #17690

@crazycs520 crazycs520 merged commit 35e2d3a into pingcap:master Jun 5, 2020
sre-bot pushed a commit to sre-bot/tidb that referenced this pull request Jun 5, 2020
@sre-bot
Copy link
Contributor

sre-bot commented Jun 5, 2020

cherry pick to release-4.0 in PR #17694

sre-bot added a commit that referenced this pull request Jun 6, 2020
…log query (#17637) (#17694)

* cherry pick #17637 to release-4.0

Signed-off-by: sre-bot <[email protected]>

* fix conflict

Signed-off-by: crazycs <[email protected]>

Co-authored-by: crazycs <[email protected]>
Co-authored-by: Lynn <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/execution SIG execution status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Flag to not print arguments in slowlog
7 participants