You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ji...@apache.org on 2020/11/03 11:32:20 UTC

[iotdb] branch cluster_new updated: fix

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

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


The following commit(s) were added to refs/heads/cluster_new by this push:
     new c7e02fc  fix
     new 164d513  Merge pull request #1922 from LebronAl/cluster_new_fix_catchup
c7e02fc is described below

commit c7e02fce292ef744bd06d9391e491ac7dba432b4
Author: LebronAl <TX...@gmail.com>
AuthorDate: Tue Nov 3 14:59:33 2020 +0800

    fix
---
 .../iotdb/cluster/server/handlers/caller/HeartbeatHandler.java   | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/cluster/src/main/java/org/apache/iotdb/cluster/server/handlers/caller/HeartbeatHandler.java b/cluster/src/main/java/org/apache/iotdb/cluster/server/handlers/caller/HeartbeatHandler.java
index da2416a..870a248 100644
--- a/cluster/src/main/java/org/apache/iotdb/cluster/server/handlers/caller/HeartbeatHandler.java
+++ b/cluster/src/main/java/org/apache/iotdb/cluster/server/handlers/caller/HeartbeatHandler.java
@@ -85,20 +85,19 @@ public class HeartbeatHandler implements AsyncMethodCallback<HeartBeatResponse>
     Peer peer = localMember.getPeerMap()
         .computeIfAbsent(follower, k -> new Peer(localMember.getLogManager().getLastLogIndex()));
     if (!peer.isCatchUp() || !localMember.getLogManager()
-        .isLogUpToDate(lastLogTerm, lastLogIdx)) {
+        .isLogUpToDate(lastLogTerm, lastLogIdx) || !localMember.getLogManager()
+        .matchTerm(lastLogTerm, lastLogIdx)) {
       // the follower is not up-to-date
-      peer.setNextIndex(lastLogIdx + 1);
       if (peer.getMatchIndex() > lastLogIdx) {
         // the last log index becomes less than match index, maybe the follower has restarted, so
         // we need to find its match index again
         peer.setMatchIndex(-1);
       }
-      logger.debug("{}: catching up node {}, index-term: {}-{}/{}-{}, peer nextIndex {}, peer "
-              + "match index {}",
+      logger.debug("{}: catching up node {}, index-term: {}-{}/{}-{}, peer match index {}",
           memberName, follower,
           lastLogIdx, lastLogTerm,
           localLastLogIdx, localLastLogTerm,
-          peer.getNextIndex(), peer.getMatchIndex());
+          peer.getMatchIndex());
 
       // only start a catch up when the follower's lastLogIndex remains stall and unchanged for 5
       // heartbeats