File tree Expand file tree Collapse file tree
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 Original file line number Diff line number Diff line change @@ -143,7 +143,7 @@ default SnapshotInfo shouldInstallSnapshot() {
143143 // we should install snapshot if the follower needs to catch up and:
144144 // 1. there is no local log entry but there is snapshot
145145 // 2. or the follower's next index is smaller than the log start index
146- // 3. or the follower is bootstrapping and has not installed any snapshot yet
146+ // 3. or the follower is bootstrapping (i.e. not yet caught up) and has not installed any snapshot yet
147147 final FollowerInfo follower = getFollower ();
148148 final boolean isFollowerBootstrapping = getLeaderState ().isFollowerBootstrapping (follower );
149149 final SnapshotInfo snapshot = getServer ().getStateMachine ().getLatestSnapshot ();
Original file line number Diff line number Diff line change @@ -818,7 +818,9 @@ public void onFollowerSuccessAppendEntries(FollowerInfo follower) {
818818
819819 @ Override
820820 public boolean isFollowerBootstrapping (FollowerInfo follower ) {
821- return isBootStrappingPeer (follower .getId ());
821+ // It is better to check caught up than staging state
822+ // since a follower may have already caught up but still in the staging state.
823+ return !isCaughtUp (follower );
822824 }
823825
824826 private void checkStaging () {
@@ -850,7 +852,12 @@ private void checkStaging() {
850852 }
851853
852854 boolean isBootStrappingPeer (RaftPeerId peerId ) {
853- return Optional .ofNullable (stagingState ).map (s -> s .contains (peerId )).orElse (false );
855+ final Optional <LogAppender > info = getLogAppender (peerId );
856+ if (info .isPresent ()) {
857+ return !isCaughtUp (info .get ().getFollower ());
858+ }
859+ final ConfigurationStagingState staging = stagingState ;
860+ return staging != null && staging .contains (peerId );
854861 }
855862
856863 void submitUpdateCommitEvent () {
You can’t perform that action at this time.
0 commit comments