From 8f71c7a3319fd0326b06a697c4727e4ffebbe528 Mon Sep 17 00:00:00 2001 From: lichaoyong Date: Thu, 28 May 2020 14:35:40 +0800 Subject: [PATCH] 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. --- be/src/olap/olap_cond.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/be/src/olap/olap_cond.cpp b/be/src/olap/olap_cond.cpp index c0f4494657..4580fe00cc 100644 --- a/be/src/olap/olap_cond.cpp +++ b/be/src/olap/olap_cond.cpp @@ -649,16 +649,14 @@ bool Conditions::delete_conditions_eval(const RowCursor& row) const { } bool Conditions::rowset_pruning_filter(const std::vector& 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& 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.