Ivan Andika created RATIS-2822:
----------------------------------
Summary: Avoid marking a no-op snapshot notification as
installation in progress
Key: RATIS-2822
URL: https://issues.apache.org/jira/browse/RATIS-2822
Project: Ratis
Issue Type: Improvement
Reporter: Ivan Andika
Assignee: Ivan Andika
During follower read benchmark, we encountered ReadIndexException due to the
InstallSnapshot RATIS-2511, but when the follower checks that it has
ALREADY_INSTALLED.
The issue is that even when inProgressInstallSnapshotIndex will eventually
trigger ALREADY_INSTALLED, we still set
inProgressInstallSnapshotIndex.compareAndSet(INVALID_LOG_INDEX,
firstAvailableLogIndex) first and then revert back to INVALID_LOG_INDEX. In the
middle of this, a read can comes in and see that inProgressInstallSnapshotIndex
is set and throw ReadIndexException.
{code:java}
if (inProgressInstallSnapshotIndex.compareAndSet(INVALID_LOG_INDEX,
firstAvailableLogIndex)) {
LOG.info("{}: Received notification to install snapshot at index {}",
getMemberId(), firstAvailableLogIndex);
// Check if snapshot index is already at par or ahead of the first
// available log index of the Leader.
final long snapshotIndex = state.getLog().getSnapshotIndex();
if (snapshotIndex != INVALID_LOG_INDEX && snapshotIndex + 1 >=
firstAvailableLogIndex &&
firstAvailableLogIndex > INVALID_LOG_INDEX) {
// State Machine has already installed the snapshot. Return the
// latest snapshot index to the Leader.
inProgressInstallSnapshotIndex.compareAndSet(firstAvailableLogIndex,
INVALID_LOG_INDEX);
LOG.info("{}: InstallSnapshot notification result: {}, current snapshot
index: {}", getMemberId(),
InstallSnapshotResult.ALREADY_INSTALLED, snapshotIndex);
final InstallSnapshotReplyProto reply =
toInstallSnapshotReplyProto(leaderId, getMemberId(), currentTerm,
InstallSnapshotResult.ALREADY_INSTALLED, snapshotIndex);
return future.thenApply(dummy -> reply);
}
{code}
We should check whether the snapshot already covers the requested boundary
first (under server monitor). Set the installation flag only when installation
is actually required.
This directly prevents the transient ReadIndex failures during
{{{}ALREADY_INSTALLED{}}}, while retaining protection during real installation.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)