This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
The following commit(s) were added to refs/heads/master by this push:
new 5199a17 [cache][be]Fix the bug of cross-border access cache (#4639)
5199a17 is described below
commit 5199a17a4b0db6cf380ba7c2b4aa0386fa48a2a3
Author: HaiBo Li <[email protected]>
AuthorDate: Mon Sep 28 13:35:52 2020 +0800
[cache][be]Fix the bug of cross-border access cache (#4639)
* When the different partition of the table is updated frequently, the
partition key list of the cache is discontinuous,
and the partition key in the request cannot hit the key list in the cache,
resulting in the access overrun,the BE will crash.
* Add some unit test case,add test cases that fail to hit the boundary
value of cache
---
be/src/runtime/cache/result_node.cpp | 17 +++++++-----
be/test/runtime/cache/partition_cache_test.cpp | 36 ++++++++++++++++++++++++++
2 files changed, 47 insertions(+), 6 deletions(-)
diff --git a/be/src/runtime/cache/result_node.cpp
b/be/src/runtime/cache/result_node.cpp
index 7813458..6924bae 100644
--- a/be/src/runtime/cache/result_node.cpp
+++ b/be/src/runtime/cache/result_node.cpp
@@ -167,14 +167,19 @@ PCacheStatus ResultNode::fetch_partition(const
PFetchCacheRequest* request,
request->params(param_idx).partition_key() >
(*part_it)->get_partition_key()) {
part_it++;
}
- while (param_idx < request->params_size() &&
- request->params(param_idx).partition_key() <
(*part_it)->get_partition_key()) {
- param_idx++;
- }
- if (request->params(param_idx).partition_key() ==
(*part_it)->get_partition_key()) {
- find = true;
+ if (part_it != _partition_list.end()) {
+ while (param_idx < request->params_size() &&
+ request->params(param_idx).partition_key() <
(*part_it)->get_partition_key()) {
+ param_idx++;
+ }
+ if (param_idx < request->params_size()) {
+ if (request->params(param_idx).partition_key() ==
(*part_it)->get_partition_key()) {
+ find = true;
+ }
+ }
}
}
+
if (find) {
#ifdef PARTITION_CACHE_DEV
LOG(INFO) << "Find! Param index : " << param_idx
diff --git a/be/test/runtime/cache/partition_cache_test.cpp
b/be/test/runtime/cache/partition_cache_test.cpp
index e370a78..4d65020 100644
--- a/be/test/runtime/cache/partition_cache_test.cpp
+++ b/be/test/runtime/cache/partition_cache_test.cpp
@@ -192,6 +192,42 @@ TEST_F(PartitionCacheTest, fetch_range_data) {
clear();
}
+TEST_F(PartitionCacheTest, fetch_invalid_right_range) {
+ init_default();
+ init_batch_data(1, 1, 3);
+
+ set_sql_key(_fetch_request->mutable_sql_key(), 1, 1);
+ PCacheParam* p1 = _fetch_request->add_params();
+ p1->set_partition_key(4);
+ p1->set_last_version(4);
+ p1->set_last_version_time(4);
+ PCacheParam* p2 = _fetch_request->add_params();
+ p2->set_partition_key(5);
+ p2->set_last_version(5);
+ p2->set_last_version_time(5);
+ _cache->fetch(_fetch_request, _fetch_result);
+
+ ASSERT_TRUE(_fetch_result->status() == PCacheStatus::NO_PARTITION_KEY);
+ ASSERT_EQ(_fetch_result->values_size(), 0);
+ clear();
+}
+
+TEST_F(PartitionCacheTest, fetch_invalid_left_range) {
+ init_default();
+ init_batch_data(1, 1, 3);
+
+ set_sql_key(_fetch_request->mutable_sql_key(), 1, 1);
+ PCacheParam* p1 = _fetch_request->add_params();
+ p1->set_partition_key(0);
+ p1->set_last_version(0);
+ p1->set_last_version_time(0);
+ _cache->fetch(_fetch_request, _fetch_result);
+
+ ASSERT_TRUE(_fetch_result->status() == PCacheStatus::NO_PARTITION_KEY);
+ ASSERT_EQ(_fetch_result->values_size(), 0);
+ clear();
+}
+
TEST_F(PartitionCacheTest, fetch_invalid_key_range) {
init_default();
init_batch_data(1, 2, 1);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]