szetszwo commented on code in PR #1173:
URL: https://github.com/apache/ratis/pull/1173#discussion_r1824824103
##########
ratis-server/src/main/java/org/apache/ratis/server/impl/SnapshotInstallationHandler.java:
##########
@@ -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);
Review Comment:
Let's call it `chunk0CallId ` and add javadoc:
```java
/** The callId of the chunk with index 0. */
private final AtomicLong chunk0CallId = new AtomicLong(-1);
```
##########
ratis-server/src/main/java/org/apache/ratis/server/impl/SnapshotInstallationHandler.java:
##########
@@ -176,8 +177,16 @@ private CompletableFuture<InstallSnapshotReplyProto>
checkAndInstallSnapshot(Ins
state.setLeader(leaderId, "installSnapshot");
server.updateLastRpcTime(FollowerState.UpdateType.INSTALL_SNAPSHOT_START);
+ if (callId.get() > request.getServerRequest().getCallId()) {
+ LOG.warn("{}: Ignoring stale snapshot request {}", getMemberId(),
+ ServerStringUtils.toInstallSnapshotRequestString(request));
Review Comment:
Print also the `chunk0CallId`
```java
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);
}
```
--
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]