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

partition pruning panic when joining two TiFlash partition tables #27674

Closed
qw4990 opened this issue Aug 30, 2021 · 6 comments
Closed

partition pruning panic when joining two TiFlash partition tables #27674

qw4990 opened this issue Aug 30, 2021 · 6 comments
Assignees
Labels
component/tablepartition This issue is related to Table Partition of TiDB. severity/major sig/planner SIG: Planner type/bug The issue is confirmed as a bug.

Comments

@qw4990
Copy link
Contributor

qw4990 commented Aug 30, 2021

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

CREATE TABLE `t1` (
  `id` varchar(100) NOT NULL
);

CREATE TABLE `t2` (
  `id` varchar(100) NOT NULL,
  `cdate` varchar(25) NOT NULL,
  PRIMARY KEY (`id`,`cdate`)
)
PARTITION BY RANGE COLUMNS(cdate) (
  PARTITION `p201905` VALUES LESS THAN ("2019-06-01"),
  PARTITION `p201906` VALUES LESS THAN ("2019-07-01")
);

ALTER TABLE t1 SET TIFLASH REPLICA 1;
ALTER TABLE t2 SET TIFLASH REPLICA 1;

-- wait for TiFlash to sync the DDL

set sql_mode='';
set @@session.tidb_allow_mpp=1;
set @@session.tidb_enforce_mpp=1;
set @@session.tidb_partition_prune_mode = 'dynamic';

EXPLAIN SELECT t2.id FROM t1 JOIN t2  ON t1.id = t2.id;

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

The explain can be processed successfully.

3. What did you see instead (Required)

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

4. What is your TiDB version? (Required)

v5.1.1

@qw4990 qw4990 added type/bug The issue is confirmed as a bug. sig/planner SIG: Planner severity/major labels Aug 30, 2021
@qw4990 qw4990 self-assigned this Aug 30, 2021
@qw4990
Copy link
Contributor Author

qw4990 commented Aug 30, 2021

I'll fix this problem in Sprint5

@mjonss
Copy link
Contributor

mjonss commented Nov 30, 2021

/component tablepartition

@ti-chi-bot ti-chi-bot added the component/tablepartition This issue is related to Table Partition of TiDB. label Nov 30, 2021
@lilinghai
Copy link
Contributor

can't reproduce it in master
Release Version: v6.0.0-alpha-115-g80ca34256
Edition: Community
Git Commit Hash: 80ca342
Git Branch: master
UTC Build Time: 2022-03-16 10:26:51
GoVersion: go1.16.4
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false

mysql> EXPLAIN SELECT t2.id FROM t1 JOIN t2  ON t1.id = t2.id;
+----------------------------------------+----------+--------------+----------------------------------+------------------------------------------------+
| id                                     | estRows  | task         | access object                    | operator info                                  |
+----------------------------------------+----------+--------------+----------------------------------+------------------------------------------------+
| TableReader_35                         | 12500.00 | root         | table of t1, partition:all of t2 | data:ExchangeSender_34                         |
| └─ExchangeSender_34                    | 12500.00 | cop[tiflash] |                                  | ExchangeType: PassThrough                      |
|   └─Projection_8                       | 12500.00 | cop[tiflash] |                                  | test.t2.id                                     |
|     └─HashJoin_33                      | 12500.00 | cop[tiflash] |                                  | inner join, equal:[eq(test.t1.id, test.t2.id)] |
|       ├─ExchangeReceiver_19(Build)     | 10000.00 | cop[tiflash] |                                  |                                                |
|       │ └─ExchangeSender_18            | 10000.00 | cop[tiflash] |                                  | ExchangeType: Broadcast                        |
|       │   └─TableFullScan_17           | 10000.00 | cop[tiflash] | table:t1                         | keep order:false, stats:pseudo                 |
|       └─TableFullScan_20(Probe)        | 10000.00 | cop[tiflash] | table:t2                         | keep order:false, stats:pseudo                 |
+----------------------------------------+----------+--------------+----------------------------------+------------------------------------------------+
8 rows in set (0.01 sec)

@ti-chi-bot ti-chi-bot added may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.0 labels Apr 7, 2022
@mjonss mjonss removed severity/moderate may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. may-affects-6.0 labels Apr 7, 2022
@mjonss mjonss assigned mjonss and unassigned qw4990 Apr 7, 2022
@mjonss
Copy link
Contributor

mjonss commented Apr 8, 2022

Also works in v5.4.0:

tidb> EXPLAIN SELECT t2.id FROM t1 JOIN t2  ON t1.id = t2.id;
+----------------------------------------+----------+--------------+----------------------------------+------------------------------------------------+
| id                                     | estRows  | task         | access object                    | operator info                                  |
+----------------------------------------+----------+--------------+----------------------------------+------------------------------------------------+
| TableReader_35                         | 12500.00 | root         | table of t1, partition:all of t2 | data:ExchangeSender_34                         |
| └─ExchangeSender_34                    | 12500.00 | cop[tiflash] |                                  | ExchangeType: PassThrough                      |
|   └─Projection_8                       | 12500.00 | cop[tiflash] |                                  | test.t2.id                                     |
|     └─HashJoin_33                      | 12500.00 | cop[tiflash] |                                  | inner join, equal:[eq(test.t1.id, test.t2.id)] |
|       ├─ExchangeReceiver_19(Build)     | 10000.00 | cop[tiflash] |                                  |                                                |
|       │ └─ExchangeSender_18            | 10000.00 | cop[tiflash] |                                  | ExchangeType: Broadcast                        |
|       │   └─TableFullScan_17           | 10000.00 | cop[tiflash] | table:t1                         | keep order:false, stats:pseudo                 |
|       └─TableFullScan_20(Probe)        | 10000.00 | cop[tiflash] | table:t2                         | keep order:false, stats:pseudo                 |
+----------------------------------------+----------+--------------+----------------------------------+------------------------------------------------+
8 rows in set (0.00 sec)

tidb> select tidb_version()\G
*************************** 1. row ***************************
tidb_version(): Release Version: v5.4.0
Edition: Community
Git Commit Hash: 55f3b24c1c9f506bd652ef1d162283541e428872
Git Branch: heads/refs/tags/v5.4.0
UTC Build Time: 2022-01-25 08:41:03
GoVersion: go1.16.4
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
1 row in set (0.00 sec)

@mjonss
Copy link
Contributor

mjonss commented Apr 9, 2022

5.1.4, 5.2.3 & 5.3.1 also fails:

tidb> EXPLAIN SELECT t2.id FROM t1 JOIN t2  ON t1.id = t2.id;
ERROR 1105 (HY000): runtime error: index out of range [-1]
tidb> select tidb_version()\G
*************************** 1. row ***************************
tidb_version(): Release Version: v5.1.4
Edition: Community
Git Commit Hash: 094b3e5e69d0921e2abe6907d217478bb5a7082d
Git Branch: heads/refs/tags/v5.1.4
UTC Build Time: 2022-02-10 10:06:05
GoVersion: go1.16.4
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
1 row in set (0.00 sec)
...
tidb> EXPLAIN SELECT t2.id FROM t1 JOIN t2  ON t1.id = t2.id;
ERROR 1105 (HY000): runtime error: index out of range [-1]
tidb> select tidb_version()\G
*************************** 1. row ***************************
tidb_version(): Release Version: v5.2.3
Edition: Community
Git Commit Hash: da1c21fd45a4ea5900ac16d2f4a248143f378d18
Git Branch: heads/refs/tags/v5.2.3
UTC Build Time: 2021-11-26 07:40:57
GoVersion: go1.16.4
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
1 row in set (0.00 sec)
...
tidb> EXPLAIN SELECT t2.id FROM t1 JOIN t2  ON t1.id = t2.id;
ERROR 1105 (HY000): runtime error: index out of range [-1]
tidb> select tidb_version()\G
*************************** 1. row ***************************
tidb_version(): Release Version: v5.3.1
Edition: Community
Git Commit Hash: 459917c6f83df155edcc03f6ebde24942ff73b0e
Git Branch: heads/refs/tags/v5.3.1
UTC Build Time: 2022-03-02 08:33:06
GoVersion: go1.16.4
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
1 row in set (0.00 sec)

@mjonss
Copy link
Contributor

mjonss commented Apr 11, 2022

This was fixed by #30367, closing as duplicate of #30365.

@mjonss mjonss closed this as completed Apr 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/tablepartition This issue is related to Table Partition of TiDB. severity/major sig/planner SIG: Planner type/bug The issue is confirmed as a bug.
Projects
None yet
Development

No branches or pull requests

4 participants