From 9ddf434f6b2e4070da82543c0cfc34ec8d66ec17 Mon Sep 17 00:00:00 2001 From: xinghuayu007 <1450306854@qq.com> Date: Sat, 19 Dec 2020 11:17:44 +0800 Subject: [PATCH] [Bug-Fix] Fix partition cache match bug (#5060) When partition cache is not cached continuely, range query may fail. For example, partition key 20201011 and 20201013 is cached, but rang query is between 20201011 and 20201013, the query will not hit the cache. issue:#5059 --- be/src/runtime/cache/result_node.cpp | 1 + .../runtime/cache/partition_cache_test.cpp | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/be/src/runtime/cache/result_node.cpp b/be/src/runtime/cache/result_node.cpp index d35d90c738..f188c89484 100644 --- a/be/src/runtime/cache/result_node.cpp +++ b/be/src/runtime/cache/result_node.cpp @@ -207,6 +207,7 @@ PCacheStatus ResultNode::fetch_partition(const PFetchCacheRequest* request, end_it = part_it; param_idx++; part_it++; + find = false; } else { status = PCacheStatus::DATA_OVERDUE; break; diff --git a/be/test/runtime/cache/partition_cache_test.cpp b/be/test/runtime/cache/partition_cache_test.cpp index 0b07af744b..cf0671139f 100644 --- a/be/test/runtime/cache/partition_cache_test.cpp +++ b/be/test/runtime/cache/partition_cache_test.cpp @@ -280,6 +280,31 @@ TEST_F(PartitionCacheTest, prune_data) { clear(); } +TEST_F(PartitionCacheTest, fetch_not_continue_partition) { + init_default(); + init_batch_data(1, 1, 1); + init_batch_data(1, 3, 1); + set_sql_key(_fetch_request->mutable_sql_key(), 1, 1); + PCacheParam* p1 = _fetch_request->add_params(); + p1->set_partition_key(1); + p1->set_last_version(1); + p1->set_last_version_time(1); + PCacheParam* p2 = _fetch_request->add_params(); + p2->set_partition_key(2); + p2->set_last_version(2); + p2->set_last_version_time(2); + PCacheParam* p3 = _fetch_request->add_params(); + p3->set_partition_key(3); + p3->set_last_version(1); + p3->set_last_version_time(1); + _cache->fetch(_fetch_request, _fetch_result); + ASSERT_TRUE(_fetch_result->status() == PCacheStatus::CACHE_OK); + ASSERT_EQ(_fetch_result->values_size(), 2); + ASSERT_EQ(_fetch_result->values(0).rows(0), "0123456789abcdef"); + ASSERT_EQ(_fetch_result->values(1).rows(0), "0123456789abcdef"); + clear(); +} + } // namespace doris int main(int argc, char** argv) {