[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
This commit is contained in:
HaiBo Li
2020-09-28 13:35:52 +08:00
committed by GitHub
parent 1dacadb015
commit 5199a17a4b
2 changed files with 47 additions and 6 deletions

View File

@ -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