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

planner: move checks for noop functions in select statements to preprocess #53279

Merged
merged 1 commit into from
May 17, 2024

Conversation

henrybw
Copy link
Contributor

@henrybw henrybw commented May 15, 2024

What problem does this PR solve?

Issue Number: close #52432

Problem Summary:

The LOCK IN SHARE MODE clause for SELECT statements is currently a noop, controlled by tidb_enable_noop_functions: when tidb_enable_noop_functions=OFF, using a noop like LOCK IN SHARE MODE should cause an error. However, point-get queries use a special "fast path" that accidentally bypasses this noop check, meaning that a query like select * from t where a=1 lock in share mode; (where a is a key column) will run even when tidb_enable_noop_functions=OFF.

What changed and how does it work?

  • Move the checks for noop functionality in SELECT statements (both LOCK IN SHARE MODE and SQL_CALC_FOUND_ROWS) out of buildLogicalPlan and into Preprocess, which runs before the TryFastPlan fast path for point-get queries.
  • Add a new noop_functions test case to integrationtest, testing the noop function checks for both LOCK IN SHARE MODE and SQL_CALC_FOUND_ROWS based on the existing TestNoopFunctions "unit test" in pkg/expression/integration_test/integration_test.go.

Check List

Tests

  • Unit test
  • 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

@sre-bot
Copy link
Contributor

sre-bot commented May 15, 2024

CLA assistant check
All committers have signed the CLA.

@ti-chi-bot ti-chi-bot bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label May 15, 2024
Copy link

tiprow bot commented May 15, 2024

Hi @henrybw. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Copy link

codecov bot commented May 15, 2024

Codecov Report

Attention: Patch coverage is 83.33333% with 4 lines in your changes are missing coverage. Please review.

Project coverage is 73.9689%. Comparing base (acdb6f5) to head (d32550b).
Report is 23 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #53279        +/-   ##
================================================
+ Coverage   72.4943%   73.9689%   +1.4746%     
================================================
  Files          1493       1499         +6     
  Lines        429359     437655      +8296     
================================================
+ Hits         311261     323729     +12468     
+ Misses        98889      93749      -5140     
- Partials      19209      20177       +968     
Flag Coverage Δ
integration 49.1701% <83.3333%> (?)
unit 71.2385% <100.0000%> (-0.1583%) ⬇️

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

Components Coverage Δ
dumpling 53.9957% <ø> (ø)
parser ∅ <ø> (∅)
br 50.7974% <ø> (+9.3404%) ⬆️

@D3Hunter D3Hunter requested a review from bb7133 May 15, 2024 05:26
@lance6716
Copy link
Contributor

/cc @hawkingrei

@ti-chi-bot ti-chi-bot bot requested a review from hawkingrei May 16, 2024 02:03
Copy link

ti-chi-bot bot commented May 16, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-05-15 09:31:24.172425477 +0000 UTC m=+1645637.929561047: ☑️ agreed by D3Hunter.
  • 2024-05-16 05:56:48.976861348 +0000 UTC m=+1719162.733996921: ☑️ agreed by tangenta.

@henrybw
Copy link
Contributor Author

henrybw commented May 16, 2024

/retest

Copy link

tiprow bot commented May 16, 2024

@henrybw: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Copy link

ti-chi-bot bot commented May 17, 2024

[APPROVALNOTIFIER] This PR is APPROVED

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

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 May 17, 2024
@hawkingrei
Copy link
Member

/retest

@ti-chi-bot ti-chi-bot bot merged commit 491740b into pingcap:master May 17, 2024
23 checks passed
@henrybw henrybw deleted the issue52432-noop-funcs-point-get branch May 17, 2024 01:38
terry1purcell pushed a commit to terry1purcell/tidb that referenced this pull request May 17, 2024
RidRisR pushed a commit to RidRisR/tidb that referenced this pull request May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note-none sig/planner SIG: Planner size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

txn: unexpected behavior for point-get and LOCK IN SHARE MODE
6 participants