xy720 commented on code in PR #33028:
URL: https://github.com/apache/doris/pull/33028#discussion_r1545722355


##########
fe/fe-core/src/main/java/org/apache/doris/cloud/transaction/CloudGlobalTransactionMgr.java:
##########
@@ -548,11 +548,25 @@ private void getPartitionInfo(List<OlapTable> tableList,
 
     private Map<Long, Long> getPartitionVersions(Map<Long, Partition> 
partitionMap) {
         Map<Long, Long> partitionToVersions = Maps.newHashMap();
+        List<CloudPartition> cloudPartitions = Lists.newArrayList();
         partitionMap.forEach((key, value) -> {
-            long visibleVersion = value.getVisibleVersion();
-            long newVersion = visibleVersion <= 0 ? 2 : visibleVersion + 1;
-            partitionToVersions.put(key, newVersion);
+            if (value instanceof CloudPartition) {
+                cloudPartitions.add((CloudPartition) value);
+            } else {
+                long visibleVersion = value.getVisibleVersion();
+                long newVersion = visibleVersion <= 0 ? 2 : visibleVersion + 1;
+                partitionToVersions.put(key, newVersion);
+            }
         });
+        try {
+            List<Long> visibleVersion = 
CloudPartition.getSnapshotVisibleVersion(cloudPartitions);

Review Comment:
   是的,你问的很对。这里不能总是获取最新的visible version。getSnapshotVisibleVersion方法调用的meta 
service rpc方法可见meta_service.cpp的batch_get_version方法,里面get value时使用的是snapshot 
read。snapshot 
read与普通read的不同之处在于,允许其他并发的事务修改它们读取的值,而普通read在这种情况下会导致冲突并返回错误。因此这里返回的version可能并不是最新的。
   
   但是这里原来的代码逻辑分成了多次rpc去获取visible version,所以理论上来说也不能获取最新的visible 
version,因为别的事务commit时可能会修改并让分区的visible version加1。



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to