[BugFix] Fix partitioned hash join crash when enable query cache (backport #62146) (#62183)

Signed-off-by: stdpain <drfeng08@gmail.com>
Co-authored-by: stdpain <34912776+stdpain@users.noreply.github.com>
This commit is contained in:
mergify[bot] 2025-08-21 17:17:30 +08:00 committed by GitHub
parent 72c4842aa6
commit 677023a9f1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 114 additions and 1 deletions

View File

@ -329,7 +329,9 @@ StatusOr<ChunkPtr> PartitionedHashJoinProberImpl::probe_remain(RuntimeState* sta
}
void PartitionedHashJoinProberImpl::reset(RuntimeState* runtime_state) {
_probers.clear();
for (auto& prober : _probers) {
prober->reset(runtime_state);
}
_partition_input_channels.clear();
_all_input_finished = false;
_remain_partition_idx = 0;

View File

@ -0,0 +1,62 @@
-- name: test_partition_join
CREATE TABLE `t0` (
`c0` int(11) NULL COMMENT "",
`c1` varchar(20) NULL COMMENT "",
`c2` varchar(200) NULL COMMENT "",
`c3` int(11) NULL COMMENT ""
) ENGINE=OLAP
DUPLICATE KEY(`c0`, `c1`)
COMMENT "OLAP"
DISTRIBUTED BY HASH(`c0`, `c1`) BUCKETS 48
PROPERTIES (
"colocate_with" = "${uuid0}",
"replication_num" = "1",
"in_memory" = "false",
"storage_format" = "DEFAULT",
"enable_persistent_index" = "true",
"replicated_storage" = "true",
"compression" = "LZ4"
);
-- result:
-- !result
CREATE TABLE `t1` (
`c0` int(11) NULL COMMENT "",
`c1` varchar(20) NULL COMMENT "",
`c2` varchar(200) NULL COMMENT "",
`c3` int(11) NULL COMMENT ""
) ENGINE=OLAP
DUPLICATE KEY(`c0`, `c1`)
COMMENT "OLAP"
DISTRIBUTED BY HASH(`c0`, `c1`) BUCKETS 48
PROPERTIES (
"colocate_with" = "${uuid0}",
"replication_num" = "1",
"in_memory" = "false",
"storage_format" = "DEFAULT",
"enable_persistent_index" = "true",
"replicated_storage" = "true",
"compression" = "LZ4"
);
-- result:
-- !result
insert into t0 SELECT generate_series, generate_series, generate_series, generate_series FROM TABLE(generate_series(1, 1100000));
-- result:
-- !result
insert into t1 select * from t0;
-- result:
-- !result
select count(l1),count(l2), count(l3), count(l4) from (select l.c0 l1,r.c1 l2,r.c2 l3,r.c3 l4 from t0 l join [broadcast]t1 r on l.c0=r.c0 and l.c1=r.c1 group by 1,2,3,4)t;
-- result:
1100000 1100000 1100000 1100000
-- !result
set enable_query_cache = true;
-- result:
-- !result
select count(l1),count(l2), count(l3), count(l4) from (select l.c0 l1,r.c1 l2,r.c2 l3,r.c3 l4 from t0 l join [broadcast]t1 r on l.c0=r.c0 and l.c1=r.c1 group by 1,2,3,4)t;
-- result:
1100000 1100000 1100000 1100000
-- !result
select count(l1),count(l2), count(l3), count(l4) from (select l.c0 l1,r.c1 l2,r.c2 l3,r.c3 l4 from t0 l join [broadcast]t1 r on l.c0=r.c0 and l.c1=r.c1 group by 1,2,3,4)t;
-- result:
1100000 1100000 1100000 1100000
-- !result

View File

@ -0,0 +1,49 @@
-- name: test_partition_join
CREATE TABLE `t0` (
`c0` int(11) NULL COMMENT "",
`c1` varchar(20) NULL COMMENT "",
`c2` varchar(200) NULL COMMENT "",
`c3` int(11) NULL COMMENT ""
) ENGINE=OLAP
DUPLICATE KEY(`c0`, `c1`)
COMMENT "OLAP"
DISTRIBUTED BY HASH(`c0`, `c1`) BUCKETS 48
PROPERTIES (
"colocate_with" = "${uuid0}",
"replication_num" = "1",
"in_memory" = "false",
"storage_format" = "DEFAULT",
"enable_persistent_index" = "true",
"replicated_storage" = "true",
"compression" = "LZ4"
);
CREATE TABLE `t1` (
`c0` int(11) NULL COMMENT "",
`c1` varchar(20) NULL COMMENT "",
`c2` varchar(200) NULL COMMENT "",
`c3` int(11) NULL COMMENT ""
) ENGINE=OLAP
DUPLICATE KEY(`c0`, `c1`)
COMMENT "OLAP"
DISTRIBUTED BY HASH(`c0`, `c1`) BUCKETS 48
PROPERTIES (
"colocate_with" = "${uuid0}",
"replication_num" = "1",
"in_memory" = "false",
"storage_format" = "DEFAULT",
"enable_persistent_index" = "true",
"replicated_storage" = "true",
"compression" = "LZ4"
);
insert into t0 SELECT generate_series, generate_series, generate_series, generate_series FROM TABLE(generate_series(1, 1100000));
insert into t1 select * from t0;
-- basic case
select count(l1),count(l2), count(l3), count(l4) from (select l.c0 l1,r.c1 l2,r.c2 l3,r.c3 l4 from t0 l join [broadcast]t1 r on l.c0=r.c0 and l.c1=r.c1 group by 1,2,3,4)t;
-- test partition join with query cache
set enable_query_cache = true;
select count(l1),count(l2), count(l3), count(l4) from (select l.c0 l1,r.c1 l2,r.c2 l3,r.c3 l4 from t0 l join [broadcast]t1 r on l.c0=r.c0 and l.c1=r.c1 group by 1,2,3,4)t;
select count(l1),count(l2), count(l3), count(l4) from (select l.c0 l1,r.c1 l2,r.c2 l3,r.c3 l4 from t0 l join [broadcast]t1 r on l.c0=r.c0 and l.c1=r.c1 group by 1,2,3,4)t;