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

*: support tidb_redact_log for explain (#54553) #55308

Merged

Conversation

ti-chi-bot
Copy link
Member

This is an automated cherry-pick of #54553

What problem does this PR solve?

Issue Number: close #54565

Problem Summary:

What changed and how does it work?

The main issue is that TiDB's explain function does not support tidb_redact_log, which has caused this problem to occur.

Due to the substantial size of this PR, I will outline the modifications made and the tests conducted.

The changement of StringCtx

StringCtx is used to generate information in the explain function and is also utilized in log generation. Therefore, it cannot directly read ctx to determine the redact mode.

So the changement of expression package is to add the redact parameter into StringCtx and force using the redactDisable mode when to raise the error.

so I refactor the StringWithCtx's implementation of Constant,Column. but planner/core.ToString/StringifyExpressionsWithCtx is to print the debug info for testing. so it forces to use the redactDisable

pkg/util/ranger/types.go is to support the redact for the ranger.

the changement of the planner

The main focus is on the physical operator to resolve the explain output. The primary modifications include enabling the expression to support redaction by passing the redact parameter into the expression's explain method. Additionally, some parameters of the operator itself are subjected to redaction.

the changement of the ranger

Enable the range to support redaction mode.

the main test cases

  • pkg/planner/core/tests/redact
  • pkg/planner/core/plan_cache_test.go
    - avoid plan cache polluting by the redact.

Check List

Tests

  • Unit test
  1. I add some test cases to make redact results right
  2. To prevent redaction from affecting the plan cache and plan digest tests, specific tests were conducted for different redaction scenarios to observe the plan cache hit rate.
  • 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 added ok-to-test Indicates a PR is ready to be tested. release-note-none Denotes a PR that doesn't merit a release note. sig/planner SIG: Planner size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. type/cherry-pick-for-release-8.1 This PR is cherry-picked to release-8.1 from a source PR. labels Aug 8, 2024
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Aug 21, 2024
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
Copy link

codecov bot commented Aug 21, 2024

Codecov Report

Attention: Patch coverage is 64.56140% with 101 lines in your changes missing coverage. Please review.

Please upload report for BASE (release-8.1@f29a4ea). Learn more about missing BASE report.

Additional details and impacted files
@@               Coverage Diff                @@
##             release-8.1     #55308   +/-   ##
================================================
  Coverage               ?   71.1609%           
================================================
  Files                  ?       1466           
  Lines                  ?     422878           
  Branches               ?          0           
================================================
  Hits                   ?     300924           
  Misses                 ?     101441           
  Partials               ?      20513           
Flag Coverage Δ
unit 71.1609% <64.5614%> (?)

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

Components Coverage Δ
dumpling 52.9656% <0.0000%> (?)
parser ∅ <0.0000%> (?)
br 41.3284% <0.0000%> (?)

Copy link
Contributor

@windtalker windtalker left a comment

Choose a reason for hiding this comment

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

lgtm

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Aug 22, 2024
Copy link

ti-chi-bot bot commented Aug 22, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-08-21 07:45:06.723838831 +0000 UTC m=+337901.858288952: ☑️ agreed by hawkingrei.
  • 2024-08-22 01:34:07.995103057 +0000 UTC m=+402043.129553171: ☑️ agreed by windtalker.

@ti-chi-bot ti-chi-bot added the cherry-pick-approved Cherry pick PR approved by release team. label Aug 22, 2024
Copy link

ti-chi-bot bot commented Aug 22, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hawkingrei, lance6716, tangenta, windtalker

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 Aug 22, 2024
@ti-chi-bot ti-chi-bot bot merged commit a7df4f9 into pingcap:release-8.1 Aug 22, 2024
18 checks passed
hawkingrei pushed a commit to ti-chi-bot/tidb that referenced this pull request Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved cherry-pick-approved Cherry pick PR approved by release team. lgtm ok-to-test Indicates a PR is ready to be tested. release-note-none Denotes a PR that doesn't merit a release note. sig/planner SIG: Planner size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. type/cherry-pick-for-release-8.1 This PR is cherry-picked to release-8.1 from a source PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants