Skip to content

[Bug][ColocateJoin] If there are two colocate join in different Fragment. May cause "failed to get tablet" problem. #4305

@HappenLee

Description

@HappenLee

Describe the bug
There are two table.

colo:

CREATE TABLE `colo` (
  `k1` tinyint(4) NULL COMMENT "",
  `k2` smallint(6) NULL COMMENT "",
  `k3` int(11) NULL COMMENT "",
  `k4` bigint(20) SUM NULL COMMENT ""
) ENGINE=OLAP
AGGREGATE KEY(`k1`, `k2`, `k3`)
COMMENT "OLAP"
DISTRIBUTED BY HASH(`k1`, `k2`, `k3`) BUCKETS 5
CREATE TABLE `colo` (
  `k1` tinyint(4) NULL COMMENT "",
  `k2` smallint(6) NULL COMMENT "",
  `k3` int(11) NULL COMMENT "",
  `k4` bigint(20) SUM NULL COMMENT ""
) ENGINE=OLAP
AGGREGATE KEY(`k1`, `k2`, `k3`)
COMMENT "OLAP"
DISTRIBUTED BY HASH(`k1`, `k2`, `k3`) BUCKETS 5
PROPERTIES (
"replication_num" = "1",
"colocate_with" = "g1",

colo1:

CREATE TABLE `colo1` (
  `k1` tinyint(4) NULL COMMENT "",
  `k2` smallint(6) NULL COMMENT "",
  `k3` int(11) NULL COMMENT "",
  `k4` bigint(20) SUM NULL COMMENT ""
) ENGINE=OLAP
AGGREGATE KEY(`k1`, `k2`, `k3`)
COMMENT "OLAP"
DISTRIBUTED BY HASH(`k1`, `k2`, `k3`) BUCKETS 5
CREATE TABLE `colo` (
  `k1` tinyint(4) NULL COMMENT "",
  `k2` smallint(6) NULL COMMENT "",
  `k3` int(11) NULL COMMENT "",
  `k4` bigint(20) SUM NULL COMMENT ""
) ENGINE=OLAP
AGGREGATE KEY(`k1`, `k2`, `k3`)
COMMENT "OLAP"
DISTRIBUTED BY HASH(`k1`, `k2`, `k3`) BUCKETS 5
PROPERTIES (
"replication_num" = "1",
"colocate_with" = "g2",

There is important that: the colo and colo1 in different colocate group;

if we execute the SQL:

 select * from 
(select t1.k1 from colo t1, colo t2 where t1.k1 = t2.k1 and t1.k2 = t2.k2 and t1.k3 = t2.k3 )t11 
join[shuffle]
 (select t1.k1 from colo1 t1, colo1 t2 where t1.k1 = t2.k1 and t1.k2 = t2.k2 and t1.k3 = t2.k3 ) t12
 on t11.k1 = t12.k1;

try explain it:

| PLAN FRAGMENT 1                                    |
|  OUTPUT EXPRS:                                     |
|   PARTITION: HASH_PARTITIONED: `t1`.`k1`           |
|                                                    |
|   STREAM DATA SINK                                 |
|     EXCHANGE ID: 09                                |
|     UNPARTITIONED                                  |
|                                                    |
|   6:HASH JOIN                                      |
|   |  join op: INNER JOIN (PARTITIONED)             |
|   |  hash predicates:                              |
|   |  colocate: false, reason: Node type not match  |
|   |  equal join conjunct: `t1`.`k1` = `t1`.`k1`    |
|   |                                                |
|   |----8:EXCHANGE                                  |
|   |                                                |
|   7:EXCHANGE                                       |
|                                                    |
| PLAN FRAGMENT 2                                    |
|  OUTPUT EXPRS:                                     |
|   PARTITION: RANDOM                                |
|                                                    |
|   STREAM DATA SINK                                 |
|     EXCHANGE ID: 08                                |
|     HASH_PARTITIONED: `t1`.`k1`                    |
|                                                    |
|   5:HASH JOIN                                      |
|   |  join op: INNER JOIN                           |
|   |  hash predicates:                              |
|   |  colocate: true                                |
|   |  equal join conjunct: `t1`.`k1` = `t2`.`k1`    |
|   |  equal join conjunct: `t1`.`k2` = `t2`.`k2`    |
|   |  equal join conjunct: `t1`.`k3` = `t2`.`k3`    |
|   |                                                |
|   |----4:OlapScanNode                              |
|   |       TABLE: colo1                             |
|   |       PREAGGREGATION: OFF. Reason: null        |
|   |       partitions=1/1                           |
|   |       rollup: colo1                            |
|   |       tabletRatio=5/5                          |
|   |       tabletList=23014,23016,23018,23020,23022 |
|   |       cardinality=0                            |
|   |       avgRowSize=0.0                           |
|   |       numNodes=1                               |
|   |                                                |
|   3:OlapScanNode                                   |
|      TABLE: colo1                                  |
|      PREAGGREGATION: OFF. Reason: No AggregateInfo |
|      partitions=1/1                                |
|      rollup: colo1                                 |
|      tabletRatio=5/5                               |
|      tabletList=23014,23016,23018,23020,23022      |
|      cardinality=0                                 |
|      avgRowSize=0.0                                |
|      numNodes=1                                    |
|                                                    |
| PLAN FRAGMENT 3                                    |
|  OUTPUT EXPRS:                                     |
|   PARTITION: RANDOM                                |
|                                                    |
|   STREAM DATA SINK                                 |
|     EXCHANGE ID: 07                                |
|     HASH_PARTITIONED: `t1`.`k1`                    |
|                                                    |
|   2:HASH JOIN                                      |
|   |  join op: INNER JOIN                           |
|   |  hash predicates:                              |
|   |  colocate: true                                |
|   |  equal join conjunct: `t1`.`k1` = `t2`.`k1`    |
|   |  equal join conjunct: `t1`.`k2` = `t2`.`k2`    |
|   |  equal join conjunct: `t1`.`k3` = `t2`.`k3`    |
|   |                                                |
|   |----1:OlapScanNode                              |
|   |       TABLE: colo                              |
|   |       PREAGGREGATION: OFF. Reason: null        |
|   |       partitions=1/1                           |
|   |       rollup: colo                             |
|   |       tabletRatio=5/5                          |
|   |       tabletList=17008,17010,17012,17014,17016 |
|   |       cardinality=0                            |
|   |       avgRowSize=0.0                           |
|   |       numNodes=1                               |
|   |                                                |
|   0:OlapScanNode                                   |
|      TABLE: colo                                   |
|      PREAGGREGATION: OFF. Reason: No AggregateInfo |
|      partitions=1/1                                |
|      rollup: colo                                  |
|      tabletRatio=5/5                               |
|      tabletList=17008,17010,17012,17014,17016      |
|      cardinality=0                                 |
|      avgRowSize=0.0                                |
|      numNodes=1                                    |

execute the SQL report:

failed to get tablet. tablet_id=23014, with schema_hash=659615493, reason=tablet does not exist

Because the seqtoAddress map should be varible of Fragment, not the Coordinator.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions