Duplicate Key table core when predicate on metric column (#3699)

```
CREATE TABLE `query_detail` (
  `query_id` varchar(100) NULL COMMENT "",
  `start_time` datetime NULL COMMENT "",
  `end_time` datetime NULL COMMENT "",
  `latency` int(11) NULL COMMENT "unit is milliseconds",
  `state` varchar(20) NULL COMMENT "RUNNING/FINISHED/FAILED",
  `sql` varchar(1024) NULL COMMENT ""
)
DUPLICATE KEY(`query_id`)

SELECT COUNT(*) FROM query_detail WHERE start_time >= '2020-05-27 14:52:16' AND start_time < '2020-05-27 14:52:31';
```
The above query will core because of ZoneMap only in query_id.
Use start_time to match ZoneMap cause this core.
This commit is contained in:
lichaoyong
2020-05-28 14:35:40 +08:00
committed by GitHub
parent f89d970cfd
commit 8f71c7a331

View File

@ -649,16 +649,14 @@ bool Conditions::delete_conditions_eval(const RowCursor& row) const {
}
bool Conditions::rowset_pruning_filter(const std::vector<KeyRange>& zone_maps) const {
//通过所有列上的删除条件对version进行过滤
// ZoneMap will store min/max of rowset.
// The function is to filter rowset using ZoneMaps
// and query predicates.
for (auto& cond_it : _columns) {
if (_cond_column_is_key_or_duplicate(cond_it.second) && cond_it.first > zone_maps.size()) {
LOG(WARNING) << "where condition not equal zone maps size. "
<< "cond_id=" << cond_it.first
<< ", zone_map_size=" << zone_maps.size();
return false;
}
if (_cond_column_is_key_or_duplicate(cond_it.second) && !cond_it.second->eval(zone_maps.at(cond_it.first))) {
return true;
if (_cond_column_is_key_or_duplicate(cond_it.second)) {
if (cond_it.first < zone_maps.size() && !cond_it.second->eval(zone_maps.at(cond_it.first))) {
return true;
}
}
}
return false;
@ -668,7 +666,8 @@ int Conditions::delete_pruning_filter(const std::vector<KeyRange>& zone_maps) co
if (_columns.empty()) {
return DEL_NOT_SATISFIED;
}
//通过所有列上的删除条件对version进行过滤
// ZoneMap and DeletePredicate are all stored in TabletMeta.
// This function is to filter rowset using ZoneMap and Delete Predicate.
/*
* the relationship between condcolumn A and B is A & B.
* if any delete condition is not satisfied, the data can't be filtered.