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 index out of range in constructIndexJoinInnerSideTask #54534

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

joechenrh
Copy link

@joechenrh joechenrh commented Jul 10, 2024

What problem does this PR solve?

Issue Number: close #54535

Problem Summary:

When set system variable tidb_enable_inl_join_inner_multi_pattern to ON, the following SQL will get an error.

set GLOBAL tidb_enable_inl_join_inner_multi_pattern='ON';
create table ta(a1 int, a2 int, a3 int, index idx_a(a1));
create table tb(b1 int, b2 int, b3 int, index idx_b(b1));
explain SELECT /*+ inl_join(tmp) */ * FROM ta, (SELECT b1, COUNT(b3) AS cnt FROM tb GROUP BY b1, b2) as tmp where ta.a1 = tmp.b1;

ERROR 1105 (HY000): runtime error: index out of range [1] with length 1

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
Copy link

ti-chi-bot bot commented Jul 10, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign fixdb for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

Copy link

ti-chi-bot bot commented Jul 10, 2024

Welcome @joechenrh!

It looks like this is your first PR to pingcap/tidb 🎉.

I'm the bot to help you request reviewers, add labels and more, See available commands.

We want to make sure your contribution gets all the attention it needs!



Thank you, and welcome to pingcap/tidb. 😃

@ti-chi-bot ti-chi-bot bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. needs-ok-to-test labels Jul 10, 2024
Copy link

ti-chi-bot bot commented Jul 10, 2024

Hi @joechenrh. Thanks for your PR.

I'm waiting for a pingcap member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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/test-infra repository.

@ti-chi-bot ti-chi-bot bot added the sig/planner SIG: Planner label Jul 10, 2024
Copy link

tiprow bot commented Jul 10, 2024

Hi @joechenrh. 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.

@hawkingrei
Copy link
Member

/ok-to-test

Copy link

codecov bot commented Jul 10, 2024

Codecov Report

Attention: Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.

Project coverage is 70.5074%. Comparing base (cf4bb51) to head (9e369c9).
Report is 1 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #54534        +/-   ##
================================================
- Coverage   74.7249%   70.5074%   -4.2176%     
================================================
  Files          1558       1559         +1     
  Lines        363817     435869     +72052     
================================================
+ Hits         271862     307320     +35458     
- Misses        72284     108403     +36119     
- Partials      19671      20146       +475     
Flag Coverage Δ
integration 49.3923% <85.7142%> (?)

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

Components Coverage Δ
dumpling 55.1391% <ø> (-0.0503%) ⬇️
parser ∅ <ø> (∅)
br 48.4372% <ø> (+0.7107%) ⬆️
@@ -1455,12 +1455,13 @@ func (p *LogicalJoin) constructIndexJoinInnerSideTask(dsCopTask *CopTask, ds *Da
ds.TableInfo.GetPartitionInfo() == nil {
if len(path.IdxCols) < len(groupByCols) {
preferStream = false
Copy link
Member

Choose a reason for hiding this comment

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

Please add the test cases for it.

Copy link
Member

Choose a reason for hiding this comment

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

You may refer to the implementation in pkg/planner/core/issuetest/planner_issue_test.go.

@ti-chi-bot ti-chi-bot bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jul 11, 2024
@joechenrh
Copy link
Author

/retest

}
p = p.(base.PhysicalPlan).Children()[0]
}
require.True(t, ok)
Copy link
Member

Choose a reason for hiding this comment

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

You can use tk.MustQuery("explain xxx") to check whether the planner is right.

Copy link
Member

@winoros winoros left a comment

Choose a reason for hiding this comment

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

Just align with other test case name

@@ -86,3 +86,33 @@ func Test53726(t *testing.T) {
" └─TableReader_11 2.00 root data:TableFullScan_10",
" └─TableFullScan_10 2.00 cop[tikv] table:t7 keep order:false"))
}

func Test54535(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
func Test54535(t *testing.T) {
func TestIssue54535(t *testing.T) {
@AilinKid
Copy link
Contributor

/retest-required

@hawkingrei
Copy link
Member

@joechenrh Please sync the code with master.

@joechenrh
Copy link
Author

/retest-required

Copy link

ti-chi-bot bot commented Jul 25, 2024

@joechenrh: 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
idc-jenkins-ci-tidb/unit-test 9e369c9 link true /test unit-test

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ok-to-test release-note-none sig/planner SIG: Planner size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
4 participants