szetszwo commented on code in PR #1612:
URL: https://github.com/apache/ratis/pull/1612#discussion_r4567436313
##########
ratis-server/src/main/java/org/apache/ratis/server/raftlog/RaftLogBase.java:
##########
@@ -125,13 +125,13 @@ public boolean updateCommitIndex(long majorityIndex, long
currentTerm, boolean i
final long newCommitIndex = Math.min(majorityIndex, getFlushIndex());
if (oldCommittedIndex < newCommitIndex) {
if (!isLeader) {
- return commitIndex.updateIncreasingly(newCommitIndex,
traceIndexChange);
+ return commitIndex.updateToMax(newCommitIndex, traceIndexChange);
}
// Only update last committed index for current term. See §5.4.2 in
paper for details.
final TermIndex entry = getTermIndex(newCommitIndex);
if (entry != null && entry.getTerm() == currentTerm) {
- return commitIndex.updateIncreasingly(newCommitIndex,
traceIndexChange);
+ return commitIndex.updateToMax(newCommitIndex, traceIndexChange);
Review Comment:
@Elia-Renzoni , It seems that we can avoid the writeLock. Please see if it
would work.
```java
public boolean updateCommitIndex(long majorityIndex, long currentTerm,
boolean isLeader) {
final long newCommitIndex = Math.min(majorityIndex, getFlushIndex());
if (!isLeader) {
return commitIndex.updateToMax(newCommitIndex, traceIndexChange);
}
// Only update last committed index for current term. See §5.4.2 in
paper for details.
final TermIndex entry = getTermIndex(newCommitIndex);
if (entry != null && entry.getTerm() == currentTerm) {
return commitIndex.updateToMax(newCommitIndex, traceIndexChange);
}
return false;
}
```
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]