Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ default SnapshotInfo shouldInstallSnapshot() {
// we should install snapshot if the follower needs to catch up and:
// 1. there is no local log entry but there is snapshot
// 2. or the follower's next index is smaller than the log start index
// 3. or the follower is bootstrapping and has not installed any snapshot yet
// 3. or the follower is bootstrapping (i.e. not yet caught up) and has not installed any snapshot yet
final FollowerInfo follower = getFollower();
final boolean isFollowerBootstrapping = getLeaderState().isFollowerBootstrapping(follower);
final SnapshotInfo snapshot = getServer().getStateMachine().getLatestSnapshot();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,9 @@ public void onFollowerSuccessAppendEntries(FollowerInfo follower) {

@Override
public boolean isFollowerBootstrapping(FollowerInfo follower) {
return isBootStrappingPeer(follower.getId());
// It is better to check caught up than staging state
// since a follower may have already caught up but still in the staging state.
return !isCaughtUp(follower);
}

private void checkStaging() {
Expand Down Expand Up @@ -852,7 +854,12 @@ private void checkStaging() {
}

boolean isBootStrappingPeer(RaftPeerId peerId) {
return Optional.ofNullable(stagingState).map(s -> s.contains(peerId)).orElse(false);
final Optional<LogAppender> info = getLogAppender(peerId);
if (info.isPresent()) {
return !isCaughtUp(info.get().getFollower());
}
final ConfigurationStagingState staging = stagingState;
return staging != null && staging.contains(peerId);
}

void submitUpdateCommitEvent() {
Expand Down
Loading