Skip to content
Merged
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 @@ -114,26 +114,38 @@ private boolean checkMatchIndex()

int index = findLastMatchIndex(logs);
if (index == -1) {
logger.info("Cannot find matched of {} within [{}, {}] in memory", node, lo, hi);
if (judgeUseLogsInDiskToCatchUp()) {
long startIndex = peer.getMatchIndex() + 1;
long endIndex = raftMember.getLogManager().getCommitLogIndex();
List<Log> logsInDisk = getLogsInStableEntryManager(startIndex, endIndex);
if (!logsInDisk.isEmpty()) {
logger.info(
"{}, found {} logs in disk to catch up {} , startIndex={}, endIndex={}, memoryFirstIndex={}, getFirstLogIndex={}",
name,
logsInDisk.size(),
node,
startIndex,
endIndex,
localFirstIndex,
logsInDisk.get(0).getCurrLogIndex());
logs = logsInDisk;
return true;
logger.info("{}, Cannot find matched of {} within [{}, {}] in memory", name, node, lo, hi);
if (!judgeUseLogsInDiskToCatchUp()) {
return false;
}
long startIndex = peer.getMatchIndex() + 1;
long endIndex = raftMember.getLogManager().getCommitLogIndex();
List<Log> logsInDisk = getLogsInStableEntryManager(startIndex, endIndex);
if (!logsInDisk.isEmpty()) {
logger.info(
"{}, found {} logs in disk to catch up {} , startIndex={}, endIndex={}, memoryFirstIndex={}, getFirstLogIndex={}",
name,
logsInDisk.size(),
node,
startIndex,
endIndex,
localFirstIndex,
logsInDisk.get(0).getCurrLogIndex());
logs = logsInDisk;
index = findLastMatchIndex(logs);
// the follower's matchIndex may have been updated
if (index == -1) {
return false;
}
} else {
logger.info(
"{}, Cannot find matched of {} within [{}, {}] in disk",
name,
node,
startIndex,
endIndex);
return false;
}
return false;
}
long newMatchedIndex = logs.get(index).getCurrLogIndex() - 1;
if (newMatchedIndex > lastLogIndex) {
Expand Down