GlenGeng commented on a change in pull request #289:
URL: https://github.com/apache/incubator-ratis/pull/289#discussion_r527525039
##########
File path:
ratis-server/src/main/java/org/apache/ratis/server/raftlog/RaftLog.java
##########
@@ -123,15 +123,20 @@ public boolean isOpened() {
* Update the last committed index.
* @param majorityIndex the index that has achieved majority.
* @param currentTerm the current term.
+ * @param isLeader Is this server the leader?
* @return true if update is applied; otherwise, return false, i.e. no
update required.
*/
- public boolean updateLastCommitted(long majorityIndex, long currentTerm) {
+ public boolean updateLastCommitted(long majorityIndex, long currentTerm,
boolean isLeader) {
try(AutoCloseableLock writeLock = writeLock()) {
final long oldCommittedIndex = getLastCommittedIndex();
final long newCommitIndex = Math.min(majorityIndex, getFlushIndex());
if (oldCommittedIndex < newCommitIndex) {
- // Only update last committed index for current term. See §5.4.2 in
- // paper for details.
+ if (!isLeader) {
Review comment:
<img width="646" alt="截屏2020-11-20 下午4 32 16"
src="https://user-images.githubusercontent.com/8412672/99777973-0702ce80-2b4e-11eb-9505-466c122a09dc.png">
https://github.com/logcabin/logcabin/blob/master/Server/RaftConsensus.cc
This is how the author of raft handle this issue: he shrinks the commit
index that it sends to the followers.
For above heartbeat case, since no entries is packed into the append entries
request, the commit index received by the follower is just preLogIndex.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]