weizuo93 commented on a change in pull request #6513:
URL: https://github.com/apache/incubator-doris/pull/6513#discussion_r698200356



##########
File path: fe/fe-core/src/main/java/org/apache/doris/clone/TabletSchedCtx.java
##########
@@ -499,10 +501,26 @@ public void chooseSrcReplica(Map<Long, PathSlot> 
backendsWorkingSlots) throws Sc
             
             long srcPathHash = slot.takeSlot(srcReplica.getPathHash());
             if (srcPathHash != -1) {
-                setSrc(srcReplica);
-                return;
+                if (!findSrcReplica) {
+                    // version count is set by report process, so it may not 
be set yet and default value is -1.
+                    // so we need to check it.
+                    minVersionCount = srcReplica.getVersionCount() == -1 ? 
Long.MAX_VALUE : srcReplica.getVersionCount();
+                    setSrc(srcReplica);
+                    findSrcReplica = true;
+                } else {
+                    long curVerCount = srcReplica.getVersionCount() == -1 ? 
Long.MAX_VALUE : srcReplica.getVersionCount();
+                    if (curVerCount < minVersionCount) {
+                        minVersionCount = curVerCount;
+                        setSrc(srcReplica);
+                        findSrcReplica = true;
+                    }
+                }
             }
         }
+
+        if (findSrcReplica) {

Review comment:
       It's necessary to record first candidate replica in the `if` block.




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