From 73b89b58f331e46dcc1d81223d80a9f2b217b6bf Mon Sep 17 00:00:00 2001 From: Yingchun Lai <405403881@qq.com> Date: Wed, 24 Feb 2021 11:23:19 +0800 Subject: [PATCH] [Bug][Cache] Version should not be considered when find the latest partition (#5408) When a table has multiple partitions, each partition has it's own version, the version doesn't represent whether it's newer or not. When a partition has a large version, it may be considered as the largest one currently, this will cause incorrect query result. Suppose there are 2 partitions: PartitionName | VisibleVersion | VisibleVersionTime p1 | 123 | 2021-02-17 23:31:32 p2 | 23 | 2021-02-22 11:39:19 Partition p1 will be considered as the lastest partition, and there is a cache before p2's last update time, the cache will hit and return an error result. --- .../src/main/java/org/apache/doris/qe/cache/CacheAnalyzer.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/cache/CacheAnalyzer.java b/fe/fe-core/src/main/java/org/apache/doris/qe/cache/CacheAnalyzer.java index 32e287846b..ddd272542c 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/qe/cache/CacheAnalyzer.java +++ b/fe/fe-core/src/main/java/org/apache/doris/qe/cache/CacheAnalyzer.java @@ -416,8 +416,7 @@ public class CacheAnalyzer { CacheTable table = new CacheTable(); table.olapTable = olapTable; for (Partition partition : olapTable.getPartitions()) { - if (partition.getVisibleVersionTime() >= table.latestTime && - partition.getVisibleVersion() > table.latestVersion) { + if (partition.getVisibleVersionTime() >= table.latestTime) { table.latestPartitionId = partition.getId(); table.latestTime = partition.getVisibleVersionTime(); table.latestVersion = partition.getVisibleVersion();