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

IndexMergeJoin on a partitioned table causes wrong result #19145

Closed
zyguan opened this issue Aug 12, 2020 · 5 comments · Fixed by #19151 or #19210
Closed

IndexMergeJoin on a partitioned table causes wrong result #19145

zyguan opened this issue Aug 12, 2020 · 5 comments · Fixed by #19151 or #19210
Assignees
Labels
severity/critical sig/execution SIG execution type/bug This issue is a bug.
Milestone

Comments

@zyguan
Copy link
Contributor

zyguan commented Aug 12, 2020

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

drop table if exists t1, t2;

create table t1  (c_int int, c_str varchar(40), primary key (c_int) ) partition by range (c_int) ( partition p0 values less than (10), partition p1 values less than maxvalue );
create table t2  (c_int int, c_str varchar(40), primary key (c_int) ) partition by range (c_int) ( partition p0 values less than (10), partition p1 values less than maxvalue );
insert into t1 values (1, 'Alice');
insert into t2 values (1, 'Bob');

select /*+ HASH_JOIN(t1,t2) */ * from t1 join t2 on t1.c_int = t2.c_int and t1.c_str < t2.c_str;
select /*+ INL_MERGE_JOIN(t1,t2) */ * from t1 join t2 on t1.c_int = t2.c_int and t1.c_str < t2.c_str;

2. What did you expect to see? (Required)

Both selection should return

+-------+-------+-------+-------+
| c_int | c_str | c_int | c_str |
+-------+-------+-------+-------+
|     1 | Alice |     1 | Bob   |
+-------+-------+-------+-------+

3. What did you see instead (Required)

mysql> select /*+ HASH_JOIN(t1,t2) */ * from t1 join t2 on t1.c_int = t2.c_int and t1.c_str < t2.c_str;
+-------+-------+-------+-------+
| c_int | c_str | c_int | c_str |
+-------+-------+-------+-------+
|     1 | Alice |     1 | Bob   |
+-------+-------+-------+-------+
1 row in set (0.06 sec)

mysql> select /*+ INL_MERGE_JOIN(t1,t2) */ * from t1 join t2 on t1.c_int = t2.c_int and t1.c_str < t2.c_str;
Empty set (0.05 sec)

Execute select /*+ INL_MERGE_JOIN(t1,t2) */ * from t1 partition (p0) join t2 on t1.c_int = t2.c_int and t1.c_str < t2.c_str; to reproduce the issue on release-4.0 .

4. What is your TiDB version? (Required)

master @ ae779e1
release-4.0 @ 3948c7b

@zyguan zyguan added the type/bug This issue is a bug. label Aug 12, 2020
@liuzix
Copy link
Contributor

liuzix commented Aug 12, 2020

/label sig/execution

@ti-srebot ti-srebot added the sig/execution SIG execution label Aug 12, 2020
@SunRunAway SunRunAway modified the milestones: v4.0.6, v4.0.5 Aug 12, 2020
@lzmhhh123
Copy link
Contributor

@zyguan Are you sure you produce this bug on release-4.0 branch? In TiDB 4.0, the partition table can't be the inner child of index merge join. I can produce it on master branch, it's not a critical issue. And the root cause may be #18981. @tiancaiamao Please take a look.

@zyguan
Copy link
Contributor Author

zyguan commented Aug 12, 2020

@lzmhhh123 try select /*+ INL_MERGE_JOIN(t1,t2) */ * from t1 partition (p0) join t2 on t1.c_int = t2.c_int and t1.c_str < t2.c_str; or select /*+ INL_MERGE_JOIN(t1,t2) */ * from t1 join t2 on t1.c_int = t2.c_int and t1.c_str < t2.c_str and t1.c_int in (1, 2, 3);

@lzmhhh123
Copy link
Contributor

Ok, that's a bug, it seems index join, index hash join and index merge join have the same problem.

@ghost ghost added the correctness label Aug 13, 2020
@ghost ghost added this to Issue Backlog: Need Triage in SIG Runtime Kanban via automation Aug 13, 2020
SIG Runtime Kanban automation moved this from Issue Backlog: Need Triage to Develop Finished (This Week) Aug 14, 2020
@tiancaiamao tiancaiamao reopened this Aug 14, 2020
SIG Runtime Kanban automation moved this from Develop Finished (This Week) to In Progress Aug 14, 2020
@tiancaiamao
Copy link
Contributor

Reopen because the fix is only for 4.0, I'm working on the fix for master.

SIG Runtime Kanban automation moved this from In Progress to Develop Finished (This Week) Aug 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity/critical sig/execution SIG execution type/bug This issue is a bug.
Projects
No open projects
SIG Runtime Kanban
  
Develop Finished (This Week)
7 participants