You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ratis.apache.org by GitBox <gi...@apache.org> on 2022/07/08 07:58:43 UTC

[GitHub] [ratis] guohao-rosicky opened a new pull request, #676: RATIS-1618. Resolve the stream client concurrent reconnection problem

guohao-rosicky opened a new pull request, #676:
URL: https://github.com/apache/ratis/pull/676

   ## What changes were proposed in this pull request?
   
   When there is a network problem, reconnection is triggered. 
   If sending a lot of messages at the same time, multiple reconnections will be triggered. 
   In this case, we need to wait for the result of the first reconnection synchronously
   
   ## What is the link to the Apache JIRA
   
   https://issues.apache.org/jira/browse/RATIS-1618


-- 
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: issues-unsubscribe@ratis.apache.org

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


[GitHub] [ratis] guohao-rosicky commented on pull request #676: RATIS-1618. Resolve the stream client concurrent reconnection problem

Posted by GitBox <gi...@apache.org>.
guohao-rosicky commented on PR #676:
URL: https://github.com/apache/ratis/pull/676#issuecomment-1178683778

   What do you think of this change @szetszwo 


-- 
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: issues-unsubscribe@ratis.apache.org

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


[GitHub] [ratis] guohao-rosicky commented on pull request #676: RATIS-1618. Resolve the stream client concurrent reconnection problem

Posted by GitBox <gi...@apache.org>.
guohao-rosicky commented on PR #676:
URL: https://github.com/apache/ratis/pull/676#issuecomment-1183949504

   Hi, @szetszwo. Thanks for review my PR.
   The modification is complete.


-- 
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: issues-unsubscribe@ratis.apache.org

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


[GitHub] [ratis] szetszwo merged pull request #676: RATIS-1618. Resolve the stream client concurrent reconnection problem

Posted by GitBox <gi...@apache.org>.
szetszwo merged PR #676:
URL: https://github.com/apache/ratis/pull/676


-- 
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: issues-unsubscribe@ratis.apache.org

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


[GitHub] [ratis] szetszwo commented on a diff in pull request #676: RATIS-1618. Resolve the stream client concurrent reconnection problem

Posted by GitBox <gi...@apache.org>.
szetszwo commented on code in PR #676:
URL: https://github.com/apache/ratis/pull/676#discussion_r917110738


##########
ratis-netty/src/main/java/org/apache/ratis/netty/client/NettyClientStreamRpc.java:
##########
@@ -213,9 +224,11 @@ private ChannelFuture reconnect() {
     void close() {
       final ChannelFuture previous = ref.getAndSet(null);
       if (previous != null) {
-        previous.channel().close();
+        // wait channel closed, do shutdown workerGroup
+        previous.channel().close().addListener((future) -> workerGroup.shutdownGracefully());
+      } else {
+        workerGroup.shutdownGracefully();

Review Comment:
   The else is not needed since previous == null means already closed.



##########
ratis-netty/src/main/java/org/apache/ratis/netty/client/NettyClientStreamRpc.java:
##########
@@ -201,7 +202,17 @@ void scheduleReconnect(String message, Throwable cause) {
       getWorkerGroup().schedule(this::reconnect, RECONNECT.getDuration(), RECONNECT.getUnit());
     }
 
-    private ChannelFuture reconnect() {
+    private synchronized ChannelFuture reconnect() {
+      // concurrent reconnect double check
+      ChannelFuture channelFuture = ref.get();
+      if (channelFuture != null) {
+        Channel channel = channelFuture.syncUninterruptibly().channel();
+        if (channel.isActive()) {
+          LOG.info("{} is already connect use exists channel {}", this, channel);

Review Comment:
   Remove LOG.info since this is a client code.



-- 
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: issues-unsubscribe@ratis.apache.org

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