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

DB::TiFlashException: Duplicated selection in DAG request #1731

Closed
fzhedu opened this issue Apr 7, 2021 · 0 comments
Closed

DB::TiFlashException: Duplicated selection in DAG request #1731

fzhedu opened this issue Apr 7, 2021 · 0 comments
Labels
plan bugs related to plans severity/major type/bug The issue is confirmed as a bug.

Comments

@fzhedu
Copy link
Contributor

fzhedu commented Apr 7, 2021

mysql -h172.16.5.85 -P52324 -uroot -D subquery_agg10000

mysql> desc SELECT  table1 . `col_char_64` > ( SELECT   MIN(  SUBQUERY1_t1 . `col_char_64` ) AS SUBQUERY1_field1 FROM `C` AS SUBQUERY1_t1 INNER JOIN `BB` AS SUBQUERY1_t2 ON (SUBQUERY1_t2 . `col_decimal_30_10` = SUBQUERY1_t1 . `col_decimal_40_key`  ) WHERE SUBQUERY1_t2 . `col_varchar_64` < SUBQUERY1_t1 . `col_char_64` ) AS field1 FROM `H` AS table1 RIGHT OUTER JOIN (  SELECT   SUBQUERY2_t1 . * FROM `B` AS SUBQUERY2_t1 INNER JOIN `DD` AS SUBQUERY2_t2 ON (SUBQUERY2_t2 . `col_varchar_64_not_null` = SUBQUERY2_t1 . `col_varchar_key`  ) WHERE SUBQUERY2_t2 . `col_int_not_null_key` <> 8 ) AS table2 INNER JOIN (  SELECT DISTINCT  SUBQUERY3_t1 . * FROM `R` AS SUBQUERY3_t1 LEFT OUTER JOIN `E` AS SUBQUERY3_t2 ON (SUBQUERY3_t2 . `col_varchar_64_not_null` = SUBQUERY3_t1 . `col_varchar_key`  )  ) AS table3 ON (table3 . `col_varchar_key` = table2 . `col_varchar_64`  ) ON (table3 . `col_tinyint_not_null` = table2 . `col_decimal_40_key`  ) WHERE  table3 . `col_char_64_not_null` >= SOME ( SELECT   SUBQUERY4_t2 . `col_varchar_64` AS SUBQUERY4_field1 FROM `CC` AS SUBQUERY4_t1 INNER JOIN ( `G` AS SUBQUERY4_t2 LEFT OUTER JOIN `B` AS SUBQUERY4_t3 ON (SUBQUERY4_t3 . `col_varchar_key` = SUBQUERY4_t2 . `col_varchar_64_not_null`  )) ON (SUBQUERY4_t3 . `col_varchar_64_not_null` = SUBQUERY4_t2 . `col_varchar_key`  ) WHERE SUBQUERY4_t3 . `col_char_64` != table3 . `col_varchar_64` OR SUBQUERY4_t2 . `col_int_key` > SUBQUERY4_t3 . `col_tinyint_not_null` ) AND ( table1 . `col_decimal_30_10_key` = 141 AND table1 . `col_varchar_key` = table2 . `col_varchar_key` )  GROUP BY field1  ;
+-----------------------------------------------------------------+-------------+--------------+--------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| id                                                              | estRows     | task         | access object      | operator info                                                                                                                                                                                                                                                                                                                                                        |
+-----------------------------------------------------------------+-------------+--------------+--------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Projection_188                                                  | 7.99        | root         |                    | gt(subquery_agg10000.h.col_char_64, p)->Column#925                                                                                                                                                                                                                                                                                                                   |
| └─HashAgg_189                                                   | 7.99        | root         |                    | group by:Column#989, funcs:firstrow(Column#988)->subquery_agg10000.h.col_char_64                                                                                                                                                                                                                                                                                     |
|   └─Projection_480                                              | 19.51       | root         |                    | subquery_agg10000.h.col_char_64, gt(subquery_agg10000.h.col_char_64, p)->Column#989                                                                                                                                                                                                                                                                                  |
|     └─Apply_191                                                 | 19.51       | root         |                    | CARTESIAN inner join, other cond:or(ge(subquery_agg10000.r.col_char_64_not_null, Column#786), if(ne(Column#787, 0), NULL, 0))                                                                                                                                                                                                                                        |
|       ├─TableReader_215(Build)                                  | 19.51       | root         |                    | data:ExchangeSender_214                                                                                                                                                                                                                                                                                                                                              |
|       │ └─ExchangeSender_214                                    | 19.51       | cop[tiflash] |                    | ExchangeType: PassThrough                                                                                                                                                                                                                                                                                                                                            |
|       │   └─HashJoin_192                                        | 19.51       | cop[tiflash] |                    | inner join, equal:[eq(subquery_agg10000.b.col_varchar_64, subquery_agg10000.r.col_varchar_key) eq(subquery_agg10000.b.col_decimal_40_key, Column#928)]                                                                                                                                                                                                               |
|       │     ├─ExchangeReceiver_208(Build)                       | 15.61       | cop[tiflash] |                    |                                                                                                                                                                                                                                                                                                                                                                      |
|       │     │ └─ExchangeSender_207                              | 15.61       | cop[tiflash] |                    | ExchangeType: Broadcast                                                                                                                                                                                                                                                                                                                                              |
|       │     │   └─HashJoin_195                                  | 15.61       | cop[tiflash] |                    | inner join, equal:[eq(subquery_agg10000.b.col_varchar_key, subquery_agg10000.dd.col_varchar_64_not_null)]                                                                                                                                                                                                                                                            |
|       │     │     ├─ExchangeReceiver_204(Build)                 | 12.49       | cop[tiflash] |                    |                                                                                                                                                                                                                                                                                                                                                                      |
|       │     │     │ └─ExchangeSender_203                        | 12.49       | cop[tiflash] |                    | ExchangeType: Broadcast                                                                                                                                                                                                                                                                                                                                              |
|       │     │     │   └─HashJoin_196                            | 12.49       | cop[tiflash] |                    | inner join, equal:[eq(subquery_agg10000.h.col_varchar_key, subquery_agg10000.b.col_varchar_key)]                                                                                                                                                                                                                                                                     |
|       │     │     │     ├─ExchangeReceiver_200(Build)           | 9.99        | cop[tiflash] |                    |                                                                                                                                                                                                                                                                                                                                                                      |
|       │     │     │     │ └─ExchangeSender_199                  | 9.99        | cop[tiflash] |                    | ExchangeType: Broadcast                                                                                                                                                                                                                                                                                                                                              |
|       │     │     │     │   └─Selection_198                     | 9.99        | cop[tiflash] |                    | 1, eq(subquery_agg10000.h.col_decimal_30_10_key, 141), not(isnull(subquery_agg10000.h.col_varchar_key))                                                                                                                                                                                                                                                              |
|       │     │     │     │     └─TableFullScan_197               | 10000.00    | cop[tiflash] | table:table1       | keep order:false, stats:pseudo                                                                                                                                                                                                                                                                                                                                       |
|       │     │     │     └─Selection_202(Probe)                  | 7992.00     | cop[tiflash] |                    | 1, not(isnull(subquery_agg10000.b.col_varchar_64)), not(isnull(subquery_agg10000.b.col_varchar_key))                                                                                                                                                                                                                                                                 |
|       │     │     │       └─TableFullScan_201                   | 10000.00    | cop[tiflash] | table:SUBQUERY2_t1 | keep order:false, stats:pseudo                                                                                                                                                                                                                                                                                                                                       |
|       │     │     └─Selection_206(Probe)                        | 6656.67     | cop[tiflash] |                    | 1, ne(subquery_agg10000.dd.col_int_not_null_key, 8)                                                                                                                                                                                                                                                                                                                  |
|       │     │       └─TableFullScan_205                         | 10000.00    | cop[tiflash] | table:SUBQUERY2_t2 | keep order:false, stats:pseudo                                                                                                                                                                                                                                                                                                                                       |
|       │     └─Projection_209(Probe)                             | 7992.00     | cop[tiflash] |                    | subquery_agg10000.r.col_varchar_64, subquery_agg10000.r.col_char_64_not_null, subquery_agg10000.r.col_varchar_key, cast(subquery_agg10000.r.col_tinyint_not_null, decimal(20,0) BINARY)->Column#928                                                                                                                                                                  |
|       │       └─Selection_210                                   | 7992.00     | cop[tiflash] |                    | 1                                                                                                                                                                                                                                                                                                                                                                    |
|       │         └─Selection_213                                 | 9990.00     | cop[tiflash] |                    | not(isnull(subquery_agg10000.r.col_varchar_key))                                                                                                                                                                                                                                                                                                                     |
|       │           └─TableFullScan_212                           | 10000.00    | cop[tiflash] | table:SUBQUERY3_t1 | keep order:false, stats:pseudo                                                                                                                                                                                                                                                                                                                                       |
|       └─Selection_315(Probe)                                    | 0.80        | root         |                    | 1, ne(Column#788, 0)                                                                                                                                                                                                                                                                                                                                                 |
|         └─HashAgg_316                                           | 1.00        | root         |                    | funcs:min(Column#986)->Column#786, funcs:sum(Column#987)->Column#787, funcs:count(1)->Column#788                                                                                                                                                                                                                                                                     |
|           └─Projection_479                                      | 99900000.00 | root         |                    | subquery_agg10000.g.col_varchar_64, cast(isnull(subquery_agg10000.g.col_varchar_64), decimal(22,0) BINARY)->Column#987                                                                                                                                                                                                                                               |
|             └─HashJoin_321                                      | 99900000.00 | root         |                    | CARTESIAN inner join                                                                                                                                                                                                                                                                                                                                                 |
|               ├─TableReader_325(Build)                          | 10000.00    | root         |                    | data:TableFullScan_324                                                                                                                                                                                                                                                                                                                                               |
|               │ └─TableFullScan_324                             | 10000.00    | cop[tiflash] | table:SUBQUERY4_t1 | keep order:false, stats:pseudo                                                                                                                                                                                                                                                                                                                                       |
|               └─TableReader_458(Probe)                          | 12487.50    | root         |                    | data:ExchangeSender_457                                                                                                                                                                                                                                                                                                                                              |
|                 └─ExchangeSender_457                            | 12487.50    | cop[tiflash] |                    | ExchangeType: PassThrough                                                                                                                                                                                                                                                                                                                                            |
|                   └─HashJoin_422                                | 12487.50    | cop[tiflash] |                    | inner join, equal:[eq(subquery_agg10000.g.col_varchar_64_not_null, subquery_agg10000.b.col_varchar_key) eq(subquery_agg10000.g.col_varchar_key, subquery_agg10000.b.col_varchar_64_not_null)], other cond:or(ne(subquery_agg10000.b.col_char_64, subquery_agg10000.r.col_varchar_64), gt(subquery_agg10000.g.col_int_key, subquery_agg10000.b.col_tinyint_not_null)) |
|                     ├─ExchangeReceiver_454(Build)               | 9990.00     | cop[tiflash] |                    |                                                                                                                                                                                                                                                                                                                                                                      |
|                     │ └─ExchangeSender_453                      | 9990.00     | cop[tiflash] |                    | ExchangeType: Broadcast                                                                                                                                                                                                                                                                                                                                              |
|                     │   └─Selection_452                         | 9990.00     | cop[tiflash] |                    | 1, not(isnull(subquery_agg10000.g.col_varchar_key))                                                                                                                                                                                                                                                                                                                  |
|                     │     └─TableFullScan_451                   | 10000.00    | cop[tiflash] | table:SUBQUERY4_t2 | keep order:false, stats:pseudo                                                                                                                                                                                                                                                                                                                                       |
|                     └─Selection_456(Probe)                      | 9990.00     | cop[tiflash] |                    | 1, not(isnull(subquery_agg10000.b.col_varchar_key))                                                                                                                                                                                                                                                                                                                  |
|                       └─TableFullScan_455                       | 10000.00    | cop[tiflash] | table:SUBQUERY4_t3 | keep order:false, stats:pseudo                                                                                                                                                                                                                                                                                                                                       |
+-----------------------------------------------------------------+-------------+--------------+--------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
40 rows in set (0.08 sec)

ERROR 1105 (HY000) at line 1: DB::TiFlashException: Duplicated selection in DAG request
SELECT table1 . col_char_64 > ( SELECT MIN( SUBQUERY1_t1 . col_char_64 ) AS SUBQUERY1_field1 FROM C AS SUBQUERY1_t1 INNER JOIN BB AS SUBQUERY1_t2 ON (SUBQUERY1_t2 . col_decimal_30_10 = SUBQUERY1_t1 . col_decimal_40_key ) WHERE SUBQUERY1_t2 . col_varchar_64 < SUBQUERY1_t1 . col_char_64 ) AS field1 FROM H AS table1 RIGHT OUTER JOIN ( SELECT SUBQUERY2_t1 . * FROM B AS SUBQUERY2_t1 INNER JOIN DD AS SUBQUERY2_t2 ON (SUBQUERY2_t2 . col_varchar_64_not_null = SUBQUERY2_t1 . col_varchar_key ) WHERE SUBQUERY2_t2 . col_int_not_null_key <> 8 ) AS table2 INNER JOIN ( SELECT DISTINCT SUBQUERY3_t1 . * FROM R AS SUBQUERY3_t1 LEFT OUTER JOIN E AS SUBQUERY3_t2 ON (SUBQUERY3_t2 . col_varchar_64_not_null = SUBQUERY3_t1 . col_varchar_key ) ) AS table3 ON (table3 . col_varchar_key = table2 . col_varchar_64 ) ON (table3 . col_tinyint_not_null = table2 . col_decimal_40_key ) WHERE table3 . col_char_64_not_null >= SOME ( SELECT SUBQUERY4_t2 . col_varchar_64 AS SUBQUERY4_field1 FROM CC AS SUBQUERY4_t1 INNER JOIN ( G AS SUBQUERY4_t2 LEFT OUTER JOIN B AS SUBQUERY4_t3 ON (SUBQUERY4_t3 . col_varchar_key = SUBQUERY4_t2 . col_varchar_64_not_null )) ON (SUBQUERY4_t3 . col_varchar_64_not_null = SUBQUERY4_t2 . col_varchar_key ) WHERE SUBQUERY4_t3 . col_char_64 != table3 . col_varchar_64 OR SUBQUERY4_t2 . col_int_key > SUBQUERY4_t3 . col_tinyint_not_null ) AND ( table1 . col_decimal_30_10_key = 141 AND table1 . col_varchar_key = table2 . col_varchar_key ) GROUP BY field1 ;

after reduced:
create table ts (col_char_64 char(64), col_varchar_64_not_null varchar(64) not null, col_varchar_key varchar(1), id int primary key, col_varchar_64 varchar(64),col_char_64_not_null char(64) not null);
alter table ts set tiflash replica 1;

mysql> desc SELECT table2 . `col_char_64` AS field1 FROM `ts` AS table2 INNER JOIN (SELECT DISTINCT SUBQUERY3_t1 . * FROM `ts` AS SUBQUERY3_t1 LEFT OUTER JOIN `ts` AS SUBQUERY3_t2 ON SUBQUERY3_t2 . `col_varchar_64_not_null` = SUBQUERY3_t1 . `col_varchar_key`) AS table3 ON (table3 . `col_varchar_key` = table2 . `col_varchar_64`) WHERE table3 . `col_char_64_not_null` >= SOME (SELECT SUBQUERY4_t1 . `col_varchar_64` AS SUBQUERY4_field1 FROM `ts` AS SUBQUERY4_t1) GROUP BY field1 ;
+------------------------------------------+----------+-------------------+--------------------+-------------------------------------------------------------------------------------------------------------------------------+
| id                                       | estRows  | task              | access object      | operator info                                                                                                                 |
+------------------------------------------+----------+-------------------+--------------------+-------------------------------------------------------------------------------------------------------------------------------+
| HashAgg_24                               | 7992.00  | root              |                    | group by:subquery_agg10000.ts.col_char_64, funcs:firstrow(subquery_agg10000.ts.col_char_64)->subquery_agg10000.ts.col_char_64 |
| └─HashJoin_31                            | 7992.00  | root              |                    | CARTESIAN inner join, other cond:or(ge(subquery_agg10000.ts.col_char_64_not_null, Column#25), if(ne(Column#26, 0), NULL, 0))  |
|   ├─Selection_32(Build)                  | 0.80     | root              |                    | 1, ne(Column#27, 0)                                                                                                           |
|   │ └─HashAgg_53                         | 1.00     | root              |                    | funcs:min(Column#33)->Column#25, funcs:sum(Column#34)->Column#26, funcs:count(Column#35)->Column#27                           |
|   │   └─TableReader_55                   | 1.00     | root              |                    | data:ExchangeSender_54                                                                                                        |
|   │     └─ExchangeSender_54              | 1.00     | batchCop[tiflash] |                    | ExchangeType: PassThrough                                                                                                     |
|   │       └─HashAgg_36                   | 1.00     | batchCop[tiflash] |                    | funcs:min(Column#39)->Column#33, funcs:sum(Column#40)->Column#34, funcs:count(1)->Column#35                                   |
|   │         └─Projection_101             | 8000.00  | batchCop[tiflash] |                    | subquery_agg10000.ts.col_varchar_64, cast(isnull(subquery_agg10000.ts.col_varchar_64), decimal(22,0) BINARY)->Column#40       |
|   │           └─Selection_52             | 8000.00  | batchCop[tiflash] |                    | 1                                                                                                                             |
|   │             └─TableFullScan_51       | 10000.00 | batchCop[tiflash] | table:SUBQUERY4_t1 | keep order:false, stats:pseudo                                                                                                |
|   └─TableReader_82(Probe)                | 9990.00  | root              |                    | data:ExchangeSender_81                                                                                                        |
|     └─ExchangeSender_81                  | 9990.00  | cop[tiflash]      |                    | ExchangeType: PassThrough                                                                                                     |
|       └─HashJoin_68                      | 9990.00  | cop[tiflash]      |                    | inner join, equal:[eq(subquery_agg10000.ts.col_varchar_64, subquery_agg10000.ts.col_varchar_key)]                             |
|         ├─ExchangeReceiver_80(Build)     | 7992.00  | cop[tiflash]      |                    |                                                                                                                               |
|         │ └─ExchangeSender_79            | 7992.00  | cop[tiflash]      |                    | ExchangeType: Broadcast                                                                                                       |
|         │   └─Selection_74               | 7992.00  | cop[tiflash]      |                    | 1                                                                                                                             |
|         │     └─Selection_78             | 9990.00  | cop[tiflash]      |                    | not(isnull(subquery_agg10000.ts.col_varchar_key))                                                                             |
|         │       └─TableFullScan_77       | 10000.00 | cop[tiflash]      | table:SUBQUERY3_t1 | keep order:false, stats:pseudo                                                                                                |
|         └─Selection_72(Probe)            | 9990.00  | cop[tiflash]      |                    | 1, not(isnull(subquery_agg10000.ts.col_varchar_64))                                                                           |
|           └─TableFullScan_71             | 10000.00 | cop[tiflash]      | table:table2       | keep order:false, stats:pseudo                                                                                                |
+------------------------------------------+----------+-------------------+--------------------+-------------------------------------------------------------------------------------------------------------------------------+
@fzhedu fzhedu added the type/bug The issue is confirmed as a bug. label Apr 7, 2021
@zanmato1984 zanmato1984 added this to the v5.0.1 milestone Apr 13, 2021
@zanmato1984 zanmato1984 added priority/release-blocker This issue blocks a release. Please solve it ASAP. and removed priority/release-blocker This issue blocks a release. Please solve it ASAP. labels Apr 13, 2021
@zanmato1984 zanmato1984 removed this from the v5.0.1 milestone Apr 13, 2021
@fzhedu fzhedu added the plan bugs related to plans label Nov 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plan bugs related to plans severity/major type/bug The issue is confirmed as a bug.
Projects
None yet
Development

No branches or pull requests

3 participants