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

Panic/wrong reuslt when using partition table. #20558

Closed
wshwsh12 opened this issue Oct 21, 2020 · 5 comments · Fixed by #20559
Closed

Panic/wrong reuslt when using partition table. #20558

wshwsh12 opened this issue Oct 21, 2020 · 5 comments · Fixed by #20559
Assignees
Labels
severity/critical sig/planner SIG: Planner type/bug The issue is confirmed as a bug.

Comments

@wshwsh12
Copy link
Contributor

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

drop table t;
CREATE TABLE `t` (
  `fid` bigint(36) NOT NULL,
  `oty` varchar(30) DEFAULT NULL,
  `oid` int(11) DEFAULT NULL,
  `pid` bigint(20) DEFAULT NULL,
  `bid` int(11) DEFAULT NULL,
  `r5` varchar(240) DEFAULT '',
  PRIMARY KEY (`fid`)
)PARTITION BY HASH( `fid` ) PARTITIONS 4;

INSERT INTO t (fid, oty, oid, pid, bid, r5) VALUES (59, 'm',  441, 1,  2143,  'LE1264_r5');
INSERT INTO t (fid, oty, oid, pid, bid, r5) VALUES (135, 'm',  1121, 1,  2423,  'LE2008_r5');
INSERT INTO t (fid, oty, oid, pid, bid, r5) VALUES (139, 'm',  1125, 1,  2432, 'LE2005_r5');
INSERT INTO t (fid, oty, oid, pid, bid, r5) VALUES (143, 'm',  1129, 1,  2438,  'LE2006_r5');
INSERT INTO t (fid, oty, oid, pid, bid, r5) VALUES (147, 'm',  1133, 1,  2446,  'LE2014_r5');
INSERT INTO t (fid, oty, oid, pid, bid, r5) VALUES (167, 'm',  1178, 1,  2512,  'LE2055_r5');
INSERT INTO t (fid, oty, oid, pid, bid, r5) VALUES (171, 'm',  1321, 1,  2542,  'LE1006_r5');
INSERT INTO t (fid, oty, oid, pid, bid, r5) VALUES (179, 'm',  1466, 1,  2648,  'LE2171_r5');
INSERT INTO t (fid, oty, oid, pid, bid, r5) VALUES (187, 'm',  1567, 1,  2690,  'LE1293_r5');
INSERT INTO t (fid, oty, oid, pid, bid, r5) VALUES (57, 'm',  341, 1,  2102,  'LE1001_r5');
INSERT INTO t (fid, oty, oid, pid, bid, r5) VALUES (137, 'm',  1123, 1,  2427,  'LE2003_r5');
INSERT INTO t (fid, oty, oid, pid, bid, r5) VALUES (145, 'm',  1131, 1,  2442,  'LE2048_r5');
INSERT INTO t (fid, oty, oid, pid, bid, r5) VALUES (138, 'm',  1124, 1,  2429,  'LE2004_r5');
INSERT INTO t (fid, oty, oid, pid, bid, r5) VALUES (142, 'm',  1128, 1,  2436,  'LE2049_r5');
INSERT INTO t (fid, oty, oid, pid, bid, r5) VALUES (174, 'm',  1381, 1,  2602,  'LE2170_r5');
INSERT INTO t (fid, oty, oid, pid, bid, r5) VALUES (28, 'm',  81, 1,  2023,  'LE1009_r5');
INSERT INTO t (fid, oty, oid, pid, bid, r5) VALUES (60, 'm',  442, 1,  2145,  'LE1263_r5');
INSERT INTO t (fid, oty, oid, pid, bid, r5) VALUES (136, 'm',  1122, 1,  2425,  'LE2002_r5');
INSERT INTO t (fid, oty, oid, pid, bid, r5) VALUES (140, 'm',  1126, 1,  2434,  'LE2001_r5');
INSERT INTO t (fid, oty, oid, pid, bid, r5) VALUES (168, 'm',  1179, 1,  2514,  'LE2052_r5');
INSERT INTO t (fid, oty, oid, pid, bid, r5) VALUES (196, 'm',  3380, 1,  2890,  'LE1300_r5');
INSERT INTO t (fid, oty, oid, pid, bid, r5) VALUES (208, 'm',  3861, 1,  3150,  'LE1323_r5');
INSERT INTO t (fid, oty, oid, pid, bid, r5) VALUES (432, 'm',  4060, 1,  3290,  'LE1327_r5');

SELECT DISTINCT t.bid, t.r5 FROM t left join t parent on parent.oid = t.pid WHERE t.oty = 'm'; 

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

MySQL [test]> SELECT DISTINCT t.bid, t.r5 FROM t left join t parent on parent.oid = t.pid WHERE t.oty = 'm'; 
+------+-----------+
| bid  | r5        |
+------+-----------+
| 2690 | LE1293_r5 |
| 2425 | LE2002_r5 |
| 2436 | LE2049_r5 |
| 2602 | LE2170_r5 |
| 2423 | LE2008_r5 |
| 2446 | LE2014_r5 |
| 2512 | LE2055_r5 |
| 3150 | LE1323_r5 |
| 2145 | LE1263_r5 |
| 2143 | LE1264_r5 |
| 2432 | LE2005_r5 |
| 2429 | LE2004_r5 |
| 2542 | LE1006_r5 |
| 2023 | LE1009_r5 |
| 3290 | LE1327_r5 |
| 2890 | LE1300_r5 |
| 2102 | LE1001_r5 |
| 2427 | LE2003_r5 |
| 2438 | LE2006_r5 |
| 2648 | LE2171_r5 |
| 2434 | LE2001_r5 |
| 2514 | LE2052_r5 |
| 2442 | LE2048_r5 |
+------+-----------+
23 rows in set (0.001 sec)

3. What did you see instead (Required)

in 4.0, it will get runtime error: index out of range [2] with length 2 ("runtime error: index out of range [2] with length 2")
in master, it will get wrong result.

4. What is your TiDB version? (Required)

@zz-jason
Copy link
Member

how did you find this bug?

@wshwsh12
Copy link
Contributor Author

how did you find this bug?

@zz-jason It's an OnCall issue...

@ti-srebot
Copy link
Contributor

ti-srebot commented Oct 21, 2020

Please edit this comment to complete the following information

Not a bug

  1. Remove the 'type/bug' label
  2. Add notes to indicate why it is not a bug

Duplicate bug

  1. Add the 'type/duplicate' label
  2. Add the link to the original bug

Bug

Note: Make Sure that 'component', and 'severity' labels are added
Example for how to fill out the template: #20100

1. Root Cause Analysis (RCA)

When creating partition union, it uses shallow copy to copy the field Column. Two DataSource will write to the same address and make the data wrong.

2. Symptom

As the describe above. Panic or wrong result.

3. All Trigger Conditions

Using partition table. Using column pruning optimization.

4. Workaround (optional)

No.

5. Affected versions

[v4.0.7]

6. Fixed versions

[v4.0.8]

@ti-srebot
Copy link
Contributor

(WorkAroud RCA AllTriggerConditions FixedVersions AffectedVersions Symptom ) fields are empty.

@pingcap pingcap deleted a comment from ti-srebot Oct 23, 2020
@pingcap pingcap deleted a comment from ti-srebot Oct 23, 2020
@seiya-annie
Copy link

sync sig label from PR

@seiya-annie seiya-annie added sig/planner SIG: Planner and removed need-more-info labels Nov 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity/critical sig/planner SIG: Planner type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants