You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ratis.apache.org by GitBox <gi...@apache.org> on 2020/11/10 00:03:52 UTC

[GitHub] [incubator-ratis] amaliujia commented on a change in pull request #264: RATIS-1140. Add primary peer id to Raft proto and only create channels with peer for primary servers

amaliujia commented on a change in pull request #264:
URL: https://github.com/apache/incubator-ratis/pull/264#discussion_r520199444



##########
File path: ratis-netty/src/main/java/org/apache/ratis/netty/server/NettyServerStreamRpc.java
##########
@@ -247,13 +248,13 @@ public void addRaftPeers(Collection<RaftPeer> newPeers) {
     proxies.addPeers(newPeers);
   }
 
-  private StreamInfo newStreamInfo(ByteBuf buf) {
+  private StreamInfo newStreamInfo(ByteBuf buf, boolean isPrimary) {
     try {
       final RaftClientRequest request = ClientProtoUtils.toRaftClientRequest(
           RaftClientRequestProto.parseFrom(buf.nioBuffer()));
       final StateMachine stateMachine = server.getStateMachine(request.getRaftGroupId());
       return new StreamInfo(request, stateMachine.data().stream(request),
-          proxies.getDataStreamOutput(request));
+          isPrimary ? proxies.getDataStreamOutput(request) : Collections.EMPTY_LIST);

Review comment:
       Only primary server should create DataStreamOutputs for peers, otherwise it will build up a deadlock.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org