Skip to content

Commit 9f9a3e4

Browse files
[fix](filecache) fix out-of-range exception when external query (#58082)
add check for external data (lakehouse data) when get_tablet_id to avoid out-of-range exception
1 parent 7e0157b commit 9f9a3e4

3 files changed

Lines changed: 15 additions & 2 deletions

File tree

‎be/src/io/cache/file_cache_common.cpp‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,10 @@ std::optional<int64_t> get_tablet_id(std::string file_path) {
202202
return std::nullopt;
203203
}
204204

205+
if (data_prefix.length() + data_pos >= path_view.length()) {
206+
return std::nullopt;
207+
}
208+
205209
// Extract the part after "data/"
206210
path_view = path_view.substr(data_pos + data_prefix.length() + 1);
207211

‎be/test/io/cache/block_file_cache_test.cpp‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
// and modified by Doris
2020

2121
#include "block_file_cache_test_common.h"
22+
#include "olap/olap_define.h"
2223

2324
namespace doris::io {
2425

@@ -7416,6 +7417,13 @@ TEST_F(BlockFileCacheTest, reader_dryrun_when_download_file_cache) {
74167417
config::enable_reader_dryrun_when_download_file_cache = org;
74177418
}
74187419

7420+
TEST_F(BlockFileCacheTest, cached_remote_file_reader_tablet_id_guard) {
7421+
// Ensure get_tablet_id gracefully returns nullopt
7422+
std::string fake_path = "/mnt/data";
7423+
auto tablet_id = get_tablet_id(fake_path);
7424+
EXPECT_FALSE(tablet_id.has_value());
7425+
}
7426+
74197427
void move_dir_to_version1(const std::string& dirPath) {
74207428
try {
74217429
// layer 1

‎regression-test/suites/cloud_p0/cache/test_file_cache_info.groovy‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ suite("test_file_cache_info") {
5454
`c_mktsegment` string NULL
5555
)
5656
DUPLICATE KEY(`c_custkey`)
57-
DISTRIBUTED BY HASH(`c_custkey`) BUCKETS 1 // only 1 tablet
57+
DISTRIBUTED BY HASH(`c_custkey`) BUCKETS 1
5858
PROPERTIES (
5959
"file_cache_ttl_seconds" = "3600"
6060
)
@@ -126,4 +126,5 @@ suite("test_file_cache_info") {
126126
}
127127

128128
}
129-
}
129+
}
130+

0 commit comments

Comments
 (0)