Skip to content

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-7.5 This PR is cherry-picked to release-7.5 from a source PR. labels Aug 8, 2024
@ti-chi-bot ti-chi-bot added the cherry-pick-approved Cherry pick PR approved by release team. label Aug 8, 2024
@hawkingrei hawkingrei force-pushed the cherry-pick-54553-to-release-7.5 branch 2 times, most recently from 5d9b1f6 to ec9fe6a Compare September 23, 2024 09:40
@hawkingrei hawkingrei force-pushed the cherry-pick-54553-to-release-7.5 branch from e8d4b8b to 5c77eed Compare September 24, 2024 08:15
@hawkingrei
Copy link
Member

/retest

Copy link

codecov bot commented Sep 25, 2024

Codecov Report

Attention: Patch coverage is 57.04918% with 262 lines in your changes missing coverage. Please review.

Please upload report for BASE (release-7.5@55eefb6). Learn more about missing BASE report.

Additional details and impacted files
@@               Coverage Diff                @@
##             release-7.5     #55307   +/-   ##
================================================
  Coverage               ?   71.9972%           
================================================
  Files                  ?       1414           
  Lines                  ?     412241           
  Branches               ?          0           
================================================
  Hits                   ?     296802           
  Misses                 ?      95550           
  Partials               ?      19889           
Flag Coverage Δ
unit 71.9972% <57.0491%> (?)

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

Components Coverage Δ
dumpling 52.9400% <0.0000%> (?)
parser ∅ <0.0000%> (?)
br 53.5046% <0.0000%> (?)

@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Sep 25, 2024
@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Sep 25, 2024
Copy link

ti-chi-bot bot commented Sep 25, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-09-25 02:27:01.104318987 +0000 UTC m=+1619290.844742918: ☑️ agreed by hawkingrei.
  • 2024-09-25 02:29:32.932179661 +0000 UTC m=+1619442.672603599: ☑️ agreed by qw4990.

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

Copy link

ti-chi-bot bot commented Sep 25, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: D3Hunter, hawkingrei, qw4990, 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 Sep 25, 2024
@ti-chi-bot ti-chi-bot bot merged commit 115461e into pingcap:release-7.5 Sep 25, 2024
17 of 18 checks passed
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-7.5 This PR is cherry-picked to release-7.5 from a source PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants