Repository navigation
RATIS-2849. Correlate concurrent leadership-transfer election RPCs - #1721
Conversation
szetszwo
left a comment
There was a problem hiding this comment.
@ivandika3 , thanks for working on this!
Just some minor comments inlined. See also https://issues.apache.org/jira/secure/attachment/13086847/1721_review.patch
|
|
||
| static StartLeaderElectionReplyProto toStartLeaderElectionReplyProto( | ||
| RaftPeerId requestorId, RaftGroupMemberId replyId, boolean success) { | ||
| RaftPeerId requestorId, RaftGroupMemberId replyId, boolean success, long callId) { |
There was a problem hiding this comment.
In order to be consistent with ClientProtoUtils.toRaftRpcReplyProtoBuilder, let's swap success and callId, i.e.
static StartLeaderElectionReplyProto toStartLeaderElectionReplyProto(
RaftPeerId requestorId, RaftGroupMemberId replyId, long callId, boolean success) {| RaftPeerId requestorId, RaftGroupMemberId replyId, boolean success, long callId) { | ||
| return StartLeaderElectionReplyProto.newBuilder() | ||
| .setServerReply(toRaftRpcReplyProtoBuilder(requestorId, replyId, success)) | ||
| .setServerReply(toRaftRpcReplyProtoBuilder(requestorId, replyId, success).setCallId(callId)) |
There was a problem hiding this comment.
private static RaftRpcReplyProto.Builder toRaftRpcReplyProtoBuilder(
- RaftPeerId requestorId, RaftGroupMemberId replyId, boolean success) {
+ RaftPeerId requestorId, RaftGroupMemberId replyId, Long callId, boolean success) {
return ClientProtoUtils.toRaftRpcReplyProtoBuilder(
- requestorId.toByteString(), replyId.getPeerId().toByteString(), replyId.getGroupId(), null, success);
+ requestorId.toByteString(), replyId.getPeerId().toByteString(), replyId.getGroupId(), callId, success);
}- Let's add a callId parameter to toRaftRpcReplyProtoBuilder, which currently pass null callId to ClientProtoUtils.toRaftRpcReplyProtoBuilder as above.
- For the other rpcs such as toInstallSnapshotReplyProto and toReadIndexReplyProto, they probably have a similar bug. See if you would fix it here or we can fix it separately. (we can pass null as the callId parameter for now)
There was a problem hiding this comment.
Let's add a callId parameter to toRaftRpcReplyProtoBuilder, which currently pass null callId to ClientProtoUtils.toRaftRpcReplyProtoBuilder as above.
Thanks for the review, updated.
For the other rpcs such as toInstallSnapshotReplyProto and toReadIndexReplyProto, they probably have a similar bug. See if you would fix it here or we can fix it separately. (we can pass null as the callId parameter for now)
Let's address it in another ticket. Checking with AI and only InstallSnapshot can have impact since InstallSnapshot can use Netty, raised RATIS-2851 for InstallSnapshot. Currently RaftServerAsynchronousProtocol#readIndexAsync is only supported by the gRPC which does not need to call ID to correlate request and response. I raised RATIS-2852 to support the RaftServerAsynchronousProtocol for Netty (at least the readIndexAsync for now).
szetszwo
left a comment
There was a problem hiding this comment.
+1 the change looks good.
What changes were proposed in this pull request?
Generated-by: GPT 6.1 Sol
Please see https://issues.apache.org/jira/browse/RATIS-2849
We need to add callId for StartLeaderElection request and response to correlate a specific request with a response. Technically, this only affects Netty transport (not gRPC) since gRPC internal logic already correlate the request and response internally.
In Netty transport, NettyRpcProxy.Connection.replies is a map of CallID -> Reply. If we don't set this and there are two concurrent requests with default CallID 0, the latter request will fail the
Preconditions.assertNull(previous, "previous")and this can make the latter request to timeout, among other possible issues.What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/RATIS-2849
How was this patch tested?
UT.