This is an automated email from the ASF dual-hosted git repository.
szetszwo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ratis.git
The following commit(s) were added to refs/heads/master by this push:
new 64a4f0a RATIS-1415. Avoid follower gap limitation for watch requests
(#518)
64a4f0a is described below
commit 64a4f0ac2426d1d2c61806f262767a84b425aa38
Author: Lokesh Jain <[email protected]>
AuthorDate: Thu Oct 21 15:36:19 2021 +0530
RATIS-1415. Avoid follower gap limitation for watch requests (#518)
---
.../java/org/apache/ratis/server/impl/LeaderStateImpl.java | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git
a/ratis-server/src/main/java/org/apache/ratis/server/impl/LeaderStateImpl.java
b/ratis-server/src/main/java/org/apache/ratis/server/impl/LeaderStateImpl.java
index 3723600..ee3c012 100644
---
a/ratis-server/src/main/java/org/apache/ratis/server/impl/LeaderStateImpl.java
+++
b/ratis-server/src/main/java/org/apache/ratis/server/impl/LeaderStateImpl.java
@@ -734,11 +734,17 @@ class LeaderStateImpl implements LeaderState {
}
private void updateCommit() {
- getMajorityMin(FollowerInfo::getMatchIndex, raftLog::getFlushIndex)
- .ifPresent(m -> updateCommit(m.majority, m.min));
+ getMajorityMin(FollowerInfo::getMatchIndex, raftLog::getFlushIndex,
+ followerMaxGapThreshold)
+ .ifPresent(m -> updateCommit(m.majority, m.min));
}
private Optional<MinMajorityMax> getMajorityMin(ToLongFunction<FollowerInfo>
followerIndex, LongSupplier logIndex) {
+ return getMajorityMin(followerIndex, logIndex, -1);
+ }
+
+ private Optional<MinMajorityMax> getMajorityMin(ToLongFunction<FollowerInfo>
followerIndex,
+ LongSupplier logIndex, long gapThreshold) {
final RaftPeerId selfId = server.getId();
final RaftConfigurationImpl conf = server.getRaftConf();
@@ -749,7 +755,7 @@ class LeaderStateImpl implements LeaderState {
}
final long[] indicesInNewConf = getSorted(followers, includeSelf,
followerIndex, logIndex);
- final MinMajorityMax newConf = MinMajorityMax.valueOf(indicesInNewConf,
followerMaxGapThreshold);
+ final MinMajorityMax newConf = MinMajorityMax.valueOf(indicesInNewConf,
gapThreshold);
if (!conf.isTransitional()) {
return Optional.of(newConf);