Skip to content

Commit

Permalink
RATIS-1883. Next Index should be always larger than Match Index in Gr…
Browse files Browse the repository at this point in the history
…pcLogAppender (apache#914)
  • Loading branch information
Brokenice0415 authored Sep 7, 2023
1 parent a483bd4 commit b8ce6d1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ private void onNextImpl(AppendEntriesReplyProto reply) {
grpcServerMetrics.onRequestSuccess(getFollowerId().toString(), reply.getIsHearbeat());
getLeaderState().onFollowerCommitIndex(getFollower(), reply.getFollowerCommit());
if (getFollower().updateMatchIndex(reply.getMatchIndex())) {
getFollower().increaseNextIndex(reply.getMatchIndex() + 1);
getLeaderState().onFollowerSuccessAppendEntries(getFollower());
}
break;
Expand All @@ -433,7 +434,7 @@ private void onNextImpl(AppendEntriesReplyProto reply) {
case INCONSISTENCY:
grpcServerMetrics.onRequestInconsistency(getFollowerId().toString());
LOG.warn("{}: received {} reply with nextIndex {}", this, reply.getResult(), reply.getNextIndex());
updateNextIndex(reply.getNextIndex());
updateNextIndex(Math.max(getFollower().getMatchIndex() + 1, reply.getNextIndex()));
break;
default:
throw new IllegalStateException("Unexpected reply result: " + reply.getResult());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ void runTestReconfTimeout(CLUSTER cluster) throws Exception {
// start the two new peers
LOG.info("Start new peers");
for (RaftPeer np : c1.newPeers) {
cluster.restartServer(np.getId(), true);
cluster.restartServer(np.getId(), false);
}
Assert.assertTrue(client.admin().setConfiguration(c1.allPeersInNewConf).isSuccess());
}
Expand Down Expand Up @@ -422,7 +422,7 @@ void runTestBootstrapReconf(int numNewPeer, boolean startNewPeer, CLUSTER cluste
ONE_SECOND.sleep();
LOG.info("start new peer(s): {}", c1.newPeers);
for(RaftPeer p : c1.newPeers) {
cluster.restartServer(p.getId(), true);
cluster.restartServer(p.getId(), false);
}
}

Expand Down Expand Up @@ -504,7 +504,7 @@ void runTestKillLeaderDuringReconf(CLUSTER cluster) throws Exception {

LOG.info("start new peers: {}", Arrays.asList(c1.newPeers));
for (RaftPeer np : c1.newPeers) {
cluster.restartServer(np.getId(), true);
cluster.restartServer(np.getId(), false);
}

try {
Expand Down

0 comments on commit b8ce6d1

Please sign in to comment.