This is an automated email from the ASF dual-hosted git repository.

zihaoxiang pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git


The following commit(s) were added to refs/heads/dev by this push:
     new 6a05a9e309 [Chore] Remove channelsLock on onChannelInactive to avoid 
deadlock (#17084)
6a05a9e309 is described below

commit 6a05a9e309c42473484976aa4b5e9f30f7e0667f
Author: Wenjun Ruan <[email protected]>
AuthorDate: Sat Mar 29 18:27:20 2025 +0800

    [Chore] Remove channelsLock on onChannelInactive to avoid deadlock (#17084)
---
 .../extract/base/client/NettyClientHandler.java             |  7 ++++---
 .../extract/base/client/NettyRemotingClient.java            | 13 +++----------
 2 files changed, 7 insertions(+), 13 deletions(-)

diff --git 
a/dolphinscheduler-extract/dolphinscheduler-extract-base/src/main/java/org/apache/dolphinscheduler/extract/base/client/NettyClientHandler.java
 
b/dolphinscheduler-extract/dolphinscheduler-extract-base/src/main/java/org/apache/dolphinscheduler/extract/base/client/NettyClientHandler.java
index 5f50e2441c..56b0942360 100644
--- 
a/dolphinscheduler-extract/dolphinscheduler-extract-base/src/main/java/org/apache/dolphinscheduler/extract/base/client/NettyClientHandler.java
+++ 
b/dolphinscheduler-extract/dolphinscheduler-extract-base/src/main/java/org/apache/dolphinscheduler/extract/base/client/NettyClientHandler.java
@@ -43,7 +43,8 @@ public class NettyClientHandler extends 
ChannelInboundHandlerAdapter {
 
     @Override
     public void channelInactive(ChannelHandlerContext ctx) {
-        
nettyRemotingClient.closeChannel(ChannelUtils.toAddress(ctx.channel()));
+        log.info("Channel inactive: {}", ctx.channel());
+        
nettyRemotingClient.onChannelInactive(ChannelUtils.toAddress(ctx.channel()));
         ctx.channel().close();
     }
 
@@ -65,8 +66,8 @@ public class NettyClientHandler extends 
ChannelInboundHandlerAdapter {
 
     @Override
     public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
-        log.error("NettyClientHandler catch an exception : {}", 
cause.getMessage(), cause);
-        
nettyRemotingClient.closeChannel(ChannelUtils.toAddress(ctx.channel()));
+        log.error("NettyClientHandler catch an exception on channel: {}", 
ctx.channel(), cause);
+        
nettyRemotingClient.onChannelInactive(ChannelUtils.toAddress(ctx.channel()));
         ctx.channel().close();
     }
 
diff --git 
a/dolphinscheduler-extract/dolphinscheduler-extract-base/src/main/java/org/apache/dolphinscheduler/extract/base/client/NettyRemotingClient.java
 
b/dolphinscheduler-extract/dolphinscheduler-extract-base/src/main/java/org/apache/dolphinscheduler/extract/base/client/NettyRemotingClient.java
index 0d1f7a0f21..98ecb353e7 100644
--- 
a/dolphinscheduler-extract/dolphinscheduler-extract-base/src/main/java/org/apache/dolphinscheduler/extract/base/client/NettyRemotingClient.java
+++ 
b/dolphinscheduler-extract/dolphinscheduler-extract-base/src/main/java/org/apache/dolphinscheduler/extract/base/client/NettyRemotingClient.java
@@ -247,20 +247,13 @@ public class NettyRemotingClient implements AutoCloseable 
{
         try {
             channelsLock.lock();
             channels.values().forEach(Channel::close);
+            channels.clear();
         } finally {
             channelsLock.unlock();
         }
     }
 
-    public void closeChannel(Host host) {
-        try {
-            channelsLock.lock();
-            Channel channel = this.channels.remove(host);
-            if (channel != null) {
-                channel.close();
-            }
-        } finally {
-            channelsLock.unlock();
-        }
+    public void onChannelInactive(final Host host) {
+        channels.remove(host);
     }
 }

Reply via email to