- if (leaderCommit - commitIndex > syncThreshold) {
- changeSyncStatus(NOT_IN_SYNC);
- } else if (leaderCommit - commitIndex <= syncThreshold && commitIndex >= minimumExpectedIndex) {
- changeSyncStatus(IN_SYNC);
+ final long lag = leaderCommit - commitIndex;
+ if (lag > syncThreshold) {
+ LOG.debug("Lagging {} entries behind leader {}", lag, leaderId);
+ changeSyncStatus(NOT_IN_SYNC, false);
+ } else if (commitIndex >= syncTarget.minimumCommitIndex) {
+ LOG.debug("Lagging {} entries behind leader and reached {} (of expected {})", lag, leaderId, commitIndex,
+ syncTarget.minimumCommitIndex);
+ changeSyncStatus(IN_SYNC, false);