File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed
ratis-server-api/src/main/java/org/apache/ratis/server/leader
ratis-server/src/main/java/org/apache/ratis/server/impl Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -145,7 +145,7 @@ default SnapshotInfo shouldInstallSnapshot() {
145145 // we should install snapshot if the follower needs to catch up and:
146146 // 1. there is no local log entry but there is snapshot
147147 // 2. or the follower's next index is smaller than the log start index
148- // 3. or the follower is bootstrapping and has not installed any snapshot yet
148+ // 3. or the follower is bootstrapping (i.e. not yet caught up) and has not installed any snapshot yet
149149 final FollowerInfo follower = getFollower ();
150150 final boolean isFollowerBootstrapping = getLeaderState ().isFollowerBootstrapping (follower );
151151 final SnapshotInfo snapshot = getServer ().getStateMachine ().getLatestSnapshot ();
Original file line number Diff line number Diff line change @@ -820,7 +820,9 @@ public void onFollowerSuccessAppendEntries(FollowerInfo follower) {
820820
821821 @ Override
822822 public boolean isFollowerBootstrapping (FollowerInfo follower ) {
823- return isBootStrappingPeer (follower .getId ());
823+ // It is better to check caught up than staging state
824+ // since a follower may have already caught up but still in the staging state.
825+ return !isCaughtUp (follower );
824826 }
825827
826828 private void checkStaging () {
@@ -852,7 +854,12 @@ private void checkStaging() {
852854 }
853855
854856 boolean isBootStrappingPeer (RaftPeerId peerId ) {
855- return Optional .ofNullable (stagingState ).map (s -> s .contains (peerId )).orElse (false );
857+ final Optional <LogAppender > info = getLogAppender (peerId );
858+ if (info .isPresent ()) {
859+ return !isCaughtUp (info .get ().getFollower ());
860+ }
861+ final ConfigurationStagingState staging = stagingState ;
862+ return staging != null && staging .contains (peerId );
856863 }
857864
858865 void submitUpdateCommitEvent () {
You can’t perform that action at this time.
0 commit comments