-
Notifications
You must be signed in to change notification settings - Fork 429
RATIS-2183. Detect staled snapshot request. #1173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RATIS-2183. Detect staled snapshot request. #1173
Conversation
move timestamp to LogAppender
@133tosakarin , we already have
For new and old snapshotRequest detection, could we reuse them instead of adding a new timestamp? |
Thanks for the reminder, just use callId. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@133tosakarin , thanks for the update!
- Please revert the white space changes in
LogAppender
andInstallSnapshotRequests
. - See also the comments inlined.
@@ -71,6 +71,7 @@ class SnapshotInstallationHandler { | |||
private final AtomicBoolean isSnapshotNull = new AtomicBoolean(); | |||
private final AtomicLong installedIndex = new AtomicLong(INVALID_LOG_INDEX); | |||
private final AtomicInteger nextChunkIndex = new AtomicInteger(-1); | |||
private final AtomicLong callId = new AtomicLong(-1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's call it chunk0CallId
and add javadoc:
/** The callId of the chunk with index 0. */
private final AtomicLong chunk0CallId = new AtomicLong(-1);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
LOG.warn("{}: Ignoring stale snapshot request {}", getMemberId(), | ||
ServerStringUtils.toInstallSnapshotRequestString(request)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Print also the chunk0CallId
final long chunk0 = chunk0CallId.get();
if (chunk0 > request.getServerRequest().getCallId()) {
LOG.warn("{}: Snapshot Request Staled: chunk 0 callId is {} but {}", getMemberId(), chunk0,
ServerStringUtils.toInstallSnapshotRequestString(request));
final InstallSnapshotReplyProto reply = toInstallSnapshotReplyProto(leaderId, getMemberId(),
currentTerm, snapshotChunkRequest.getRequestIndex(), InstallSnapshotResult.SNAPSHOT_EXPIRED);
return future.thenApply(dummy -> reply);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 the change looks good.
@133tosakarin , thanks for working on this! @OneSizeFitsQuorum , thanks also for reviewing this! |
see https://issues.apache.org/jira/browse/RATIS-2183