Anpu Lu created RATIS-1909:
------------------------------
Summary: Fix Decreasing Next Index When GrpcLogAppender Reset
Client
Key: RATIS-1909
URL: https://issues.apache.org/jira/browse/RATIS-1909
Project: Ratis
Issue Type: Bug
Reporter: Anpu Lu
GrpcLogAppender call `resetClient` when error accors in appending entries.
In `resetClient`, the new next index `nextIndex` may be match index + 1 when
`request` is null.
This will make `getFollower().decreaseNextIndex(nextIndex);` have chance to
decrease next index to the value of match index, which is against that {*}Next
index should be larger than match index{*}.
{code:java}
// GrpcLogAppender.java:resetClient() line 134
final long nextIndex = 1 + Optional.ofNullable(request)
.map(AppendEntriesRequest::getPreviousLog)
.map(TermIndex::getIndex)
.orElseGet(f::getMatchIndex);
if (onError && request == null) {
LOG.warn("{}: Follower failed and request == null, " +
" keep nextIndex ({}) unchanged and retry.", this, f.getNextIndex());
return;
}
if (request != null && request.isHeartbeat()) {
return;
}
// new next index will be min(old-1, nextIndex)
getFollower().decreaseNextIndex(nextIndex);{code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)