This is an automated email from the ASF dual-hosted git repository.

chaow pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/master by this push:
     new 7be35d6  [IOTDB-1317] Log CatchUp always failed du to not check the 
follower's match index (#3029)
7be35d6 is described below

commit 7be35d62d0396bb6f906c0f96c383ae9298fe1d8
Author: HouliangQi <[email protected]>
AuthorDate: Tue Apr 20 18:03:17 2021 +0800

    [IOTDB-1317] Log CatchUp always failed du to not check the follower's match 
index (#3029)
---
 .../iotdb/cluster/log/catchup/CatchUpTask.java     | 48 ++++++++++++++--------
 1 file changed, 30 insertions(+), 18 deletions(-)

diff --git 
a/cluster/src/main/java/org/apache/iotdb/cluster/log/catchup/CatchUpTask.java 
b/cluster/src/main/java/org/apache/iotdb/cluster/log/catchup/CatchUpTask.java
index d04227b..1472b12 100644
--- 
a/cluster/src/main/java/org/apache/iotdb/cluster/log/catchup/CatchUpTask.java
+++ 
b/cluster/src/main/java/org/apache/iotdb/cluster/log/catchup/CatchUpTask.java
@@ -114,26 +114,38 @@ public class CatchUpTask implements Runnable {
 
     int index = findLastMatchIndex(logs);
     if (index == -1) {
-      logger.info("Cannot find matched of {} within [{}, {}] in memory", node, 
lo, hi);
-      if (judgeUseLogsInDiskToCatchUp()) {
-        long startIndex = peer.getMatchIndex() + 1;
-        long endIndex = raftMember.getLogManager().getCommitLogIndex();
-        List<Log> logsInDisk = getLogsInStableEntryManager(startIndex, 
endIndex);
-        if (!logsInDisk.isEmpty()) {
-          logger.info(
-              "{}, found {} logs in disk to catch up {} , startIndex={}, 
endIndex={}, memoryFirstIndex={}, getFirstLogIndex={}",
-              name,
-              logsInDisk.size(),
-              node,
-              startIndex,
-              endIndex,
-              localFirstIndex,
-              logsInDisk.get(0).getCurrLogIndex());
-          logs = logsInDisk;
-          return true;
+      logger.info("{}, Cannot find matched of {} within [{}, {}] in memory", 
name, node, lo, hi);
+      if (!judgeUseLogsInDiskToCatchUp()) {
+        return false;
+      }
+      long startIndex = peer.getMatchIndex() + 1;
+      long endIndex = raftMember.getLogManager().getCommitLogIndex();
+      List<Log> logsInDisk = getLogsInStableEntryManager(startIndex, endIndex);
+      if (!logsInDisk.isEmpty()) {
+        logger.info(
+            "{}, found {} logs in disk to catch up {} , startIndex={}, 
endIndex={}, memoryFirstIndex={}, getFirstLogIndex={}",
+            name,
+            logsInDisk.size(),
+            node,
+            startIndex,
+            endIndex,
+            localFirstIndex,
+            logsInDisk.get(0).getCurrLogIndex());
+        logs = logsInDisk;
+        index = findLastMatchIndex(logs);
+        // the follower's matchIndex may have been updated
+        if (index == -1) {
+          return false;
         }
+      } else {
+        logger.info(
+            "{}, Cannot find matched of {} within [{}, {}] in disk",
+            name,
+            node,
+            startIndex,
+            endIndex);
+        return false;
       }
-      return false;
     }
     long newMatchedIndex = logs.get(index).getCurrLogIndex() - 1;
     if (newMatchedIndex > lastLogIndex) {

Reply via email to