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: fix CTE hang or wrong result when multiple Apply is used #55553

Merged
merged 3 commits into from
Aug 22, 2024

Conversation

guo-shaoge
Copy link
Collaborator

@guo-shaoge guo-shaoge commented Aug 21, 2024

What problem does this PR solve?

Issue Number: close #55551

Problem Summary:
ExtractOuterApplyCorrelatedCols is used to find all correlated columns which is inside CTE definition and its corresponding Apply is outside of CTE definition. Check the following diagram, ExtractOuterApplyCorrelatedCols should NOT return cor_col_3, because cor_col_3's corresponding Apply is Apply_3, which is inside CTE definition.

Why need ExtractOuterApplyCorrelatedCols: For those CTE whose result of ExtractOuterApplyCorrelatedCols(CTE_definition) is not empty, we need to re-compute the definition of CTE.

// For Plan-2, the result of ExtractOuterApplyCorrelatedCols(CTE-2) will not return cor_col_3.
// Because Apply_3 is inside CTE-2.
// Plan-2:
//
//	Apply_2
//	 |_ outerSide
//	 |_ Selection(cor_col_2)
//	     |_CTEExec(CTE-2)
//	CTE-2
//	 |_ Apply_3
//	     |_ outerSide
//	     |_ innerSide(cor_col_3)

What changed and how does it work?

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

Signed-off-by: guo-shaoge <shaoge1994@163.com>
Signed-off-by: guo-shaoge <shaoge1994@163.com>
@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-linked-issue do-not-merge/needs-tests-checked release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. sig/planner SIG: Planner labels Aug 21, 2024
Copy link

tiprow bot commented Aug 21, 2024

Hi @guo-shaoge. 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.

@guo-shaoge guo-shaoge changed the title planner: fix CTE with Apply planner: fix CTE hang or wrong result with Apply Aug 21, 2024
Signed-off-by: guo-shaoge <shaoge1994@163.com>
@guo-shaoge guo-shaoge changed the title planner: fix CTE hang or wrong result with Apply planner: fix CTE hang or wrong result when multiple Apply is used Aug 21, 2024
@guo-shaoge guo-shaoge requested review from winoros and XuHuaiyu August 21, 2024 06:57
Copy link

codecov bot commented Aug 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 74.9432%. Comparing base (51d57aa) to head (01b0d07).
Report is 299 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #55553        +/-   ##
================================================
+ Coverage   72.8423%   74.9432%   +2.1008%     
================================================
  Files          1572       1586        +14     
  Lines        440056     454220     +14164     
================================================
+ Hits         320547     340407     +19860     
+ Misses        99747      93210      -6537     
- Partials      19762      20603       +841     
Flag Coverage Δ
integration 49.3405% <100.0000%> (?)
unit 71.9478% <100.0000%> (+0.0907%) ⬆️

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

Components Coverage Δ
dumpling 52.9567% <ø> (ø)
parser ∅ <ø> (∅)
br 51.7416% <ø> (+5.9029%) ⬆️

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

ti-chi-bot bot commented Aug 21, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-08-21 07:25:16.33368126 +0000 UTC m=+336711.468131379: ☑️ agreed by hawkingrei.
  • 2024-08-21 07:33:57.635152574 +0000 UTC m=+337232.769602696: ☑️ agreed by XuHuaiyu.

@guo-shaoge
Copy link
Collaborator Author

/hold

@ti-chi-bot ti-chi-bot bot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. do-not-merge/needs-triage-completed labels Aug 21, 2024
Copy link

tiprow bot commented Aug 21, 2024

@guo-shaoge: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
fast_test_tiprow 01b0d07 link true /test fast_test_tiprow

Full PR test history. Your PR dashboard.

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. I understand the commands that are listed here.

@hawkingrei hawkingrei self-requested a review August 21, 2024 07:39
Copy link

ti-chi-bot bot commented Aug 22, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: AilinKid, hawkingrei, XuHuaiyu

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

@guo-shaoge guo-shaoge removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 22, 2024
@ti-chi-bot ti-chi-bot bot merged commit d04ec9d into pingcap:master Aug 22, 2024
22 of 23 checks passed
@ti-chi-bot ti-chi-bot bot added the needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. label Aug 26, 2024
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-6.5: #55643.

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Aug 26, 2024
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot ti-chi-bot bot added the needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. label Sep 20, 2024
ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Sep 20, 2024
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.5: #56200.

@guo-shaoge
Copy link
Collaborator Author

/run-cherry-picker

@guo-shaoge guo-shaoge added needs-cherry-pick-release-8.1 Should cherry pick this PR to release-8.1 branch. needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. labels Sep 24, 2024
ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Sep 24, 2024
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-8.1: #56261.

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.1: #56263.

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Sep 24, 2024
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@guo-shaoge guo-shaoge added the needs-cherry-pick-release-6.1 Should cherry pick this PR to release-6.1 branch. label Sep 24, 2024
ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Sep 24, 2024
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-6.1: #56265.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm needs-cherry-pick-release-6.1 Should cherry pick this PR to release-6.1 branch. needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. needs-cherry-pick-release-8.1 Should cherry pick this PR to release-8.1 branch. 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CTE hang or result wrong when multiple Apply is used
5 participants