Conversation
Contributor
Author
|
R: @szetszwo |
szetszwo
reviewed
Sep 18, 2026
szetszwo
left a comment
Contributor
There was a problem hiding this comment.
@amaliujia , thanks for working on this! Please see the comment inlined.
Comment on lines
788
to
795
| case SNAPSHOT_EXPIRED: | ||
| LOG.warn("{}: Follower failed since the request expired, {}", | ||
| name, ServerStringUtils.toInstallSnapshotReplyString(reply)); | ||
| getFollower().setAttemptedToInstallSnapshot(); | ||
| removePending(reply); | ||
| break; | ||
| default: | ||
| break; |
Contributor
There was a problem hiding this comment.
Let's handle SNAPSHOT_EXPIRED the same way as SNAPSHOT_UNAVAILABLE:
diff --git a/ratis-grpc/src/main/java/org/apache/ratis/grpc/server/GrpcLogAppender.java b/ratis-grpc/src/main/java/org/apache/ratis/grpc/server/GrpcLogAppender.java
index e6870b9b8..60d7ee2b2 100644
--- a/ratis-grpc/src/main/java/org/apache/ratis/grpc/server/GrpcLogAppender.java
+++ b/ratis-grpc/src/main/java/org/apache/ratis/grpc/server/GrpcLogAppender.java
@@ -775,24 +775,26 @@ public class GrpcLogAppender extends LogAppenderBase {
removePending(reply);
break;
case SNAPSHOT_UNAVAILABLE:
- BatchLogger.print(BatchLogKey.SNAPSHOT_UNAVAILABLE, name,
- suffix -> LOG.info("{}: Follower failed since the snapshot is unavailable {}", this, suffix));
- getFollower().setAttemptedToInstallSnapshot();
- notifyInstallSnapshotFinished(InstallSnapshotResult.SNAPSHOT_UNAVAILABLE, RaftLog.INVALID_LOG_INDEX);
- removePending(reply);
- break;
- case UNRECOGNIZED:
- LOG.error("{}: Reply result {}, {}",
- name, reply.getResult(), ServerStringUtils.toInstallSnapshotReplyString(reply));
+ handleFailureReply(reply, BatchLogKey.SNAPSHOT_UNAVAILABLE);
break;
case SNAPSHOT_EXPIRED:
- LOG.warn("{}: Follower failed since the request expired, {}",
- name, ServerStringUtils.toInstallSnapshotReplyString(reply));
+ handleFailureReply(reply, BatchLogKey.SNAPSHOT_UNAVAILABLE);
+ break;
default:
+ LOG.error("{}: Unexpected InstallSnapshotReply result {} in {}",
+ name, reply.getResult(), ServerStringUtils.toInstallSnapshotReplyString(reply));
break;
}
}
+ private void handleFailureReply(InstallSnapshotReplyProto reply, BatchLogKey logKey) {
+ BatchLogger.print(logKey, name,
+ suffix -> LOG.info("{}: Follower failed due to {}: {}{}", this, reply.getResult(), reply, suffix));
+ getFollower().setAttemptedToInstallSnapshot();
+ notifyInstallSnapshotFinished(reply.getResult(), RaftLog.INVALID_LOG_INDEX);
+ removePending(reply);
+ }
+
@Override
public void onError(Throwable t) {
if (!isRunning()) {
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
Fix
GrpcLogAppender.InstallSnapshotResponseHandlerto properly handleSNAPSHOT_EXPIREDinstall-snapshot replies by callingremovePending(reply)andsetAttemptedToInstallSnapshot(), matching other terminal snapshot results such asSNAPSHOT_UNAVAILABLEandSUCCESS.What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/RATIS-2703
How was this patch tested?
Unit test