int replicatedCount = replicatedLogEntry.isPersistencePending() ? 0 : 1;
if (replicatedCount == 0) {
- // We don't commit and apply a log entry until we've gotten the ack from our local persistence. Ideally
- // we should be able to update the commit index if we get a consensus amongst the followers
- // w/o the local persistence ack however this can cause timing issues with snapshot capture
- // which may lead to an entry that is neither in the serialized snapshot state nor in the snapshot's
- // unapplied entries. This can happen if the lastAppliedIndex is updated but the corresponding
- // ApplyState message is still pending in the message queue and thus the corresponding log entry hasn't
- // actually been applied to the state yet. This would be alleviated by eliminating the ApplyState
- // message in lieu of synchronously updating lastAppliedIndex and applying to state.
+ // We don't commit and apply a log entry until we've gotten the ack from our local persistence,
+ // even though there *shouldn't* be any issue with updating the commit index if we get a consensus
+ // amongst the followers w/o the local persistence ack.
break;
}
/**
* This method checks if any update needs to be sent to the given follower. This includes append log entries,
* sending next snapshot chunk, and initiating a snapshot.
- *
- * @return true if any update is sent, false otherwise
*/
private void sendUpdatesToFollower(String followerId, FollowerLogInformation followerLogInformation,
boolean sendHeartbeat, boolean isHeartbeat) {
// Note: sendSnapshotChunk will set the LeaderInstallSnapshotState.
sendSnapshotChunk(followerActor, followerLogInfo);
return true;
- } else {
- boolean captureInitiated = context.getSnapshotManager().captureToInstall(context.getReplicatedLog().last(),
- this.getReplicatedToAllIndex(), followerId);
- if (captureInitiated) {
- followerLogInfo.setLeaderInstallSnapshotState(new LeaderInstallSnapshotState(
- context.getConfigParams().getSnapshotChunkSize(), logName()));
- }
+ }
- return captureInitiated;
+ boolean captureInitiated = context.getSnapshotManager().captureToInstall(context.getReplicatedLog().last(),
+ this.getReplicatedToAllIndex(), followerId);
+ if (captureInitiated) {
+ followerLogInfo.setLeaderInstallSnapshotState(new LeaderInstallSnapshotState(
+ context.getConfigParams().getSnapshotChunkSize(), logName()));
}
+
+ return captureInitiated;
}
private boolean canInstallSnapshot(long nextIndex) {