You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by do...@apache.org on 2025/10/27 00:55:10 UTC

(spark) branch master updated: [SPARK-54034][CORE] Fix `Utils.isBindCollision` to detect port conflict `NativeIoException` correctly

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

dongjoon pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/master by this push:
     new e2b107196f59 [SPARK-54034][CORE] Fix `Utils.isBindCollision` to detect port conflict `NativeIoException` correctly
e2b107196f59 is described below

commit e2b107196f593e268b9bd5ba5a4f03f6e658dd28
Author: Dongjoon Hyun <do...@apache.org>
AuthorDate: Sun Oct 26 17:54:51 2025 -0700

    [SPARK-54034][CORE] Fix `Utils.isBindCollision` to detect port conflict `NativeIoException` correctly
    
    ### What changes were proposed in this pull request?
    
    This PR aims to fix `Utils.isBindCollision` to detect port conflict NativeIoException correctly by using regular expression.
    
    ### Why are the changes needed?
    
    Currently, `Utils.isBindCollision` fails to detect port conflicts when we use native Netty transport IO modes, `EPOLL` and `KQUEUE`.
    
    **BEFORE**
    
    ```
    [info] AutoNettyRpcEnvSuite:
    [info] - port conflict *** FAILED *** (7 milliseconds)
    [info]   io.netty.channel.unix.Errors$NativeIoException: bind(..) failed with error(-48): Address already in use
    ```
    
    **AFTER**
    
    ```
    [info] AutoNettyRpcEnvSuite:
    [info] - port conflict (68 milliseconds)
    ```
    
    ### Does this PR introduce _any_ user-facing change?
    
    No, this is a bug fix.
    
    ### How was this patch tested?
    
    Pass the CI with the newly added test suite, `AutoNettyRpcEnvSuite`.
    
    ### Was this patch authored or co-authored using generative AI tooling?
    
    No.
    
    Closes #52738 from dongjoon-hyun/SPARK-54034.
    
    Authored-by: Dongjoon Hyun <do...@apache.org>
    Signed-off-by: Dongjoon Hyun <do...@apache.org>
---
 core/src/main/scala/org/apache/spark/util/Utils.scala               | 2 +-
 .../test/scala/org/apache/spark/rpc/netty/NettyRpcEnvSuite.scala    | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/core/src/main/scala/org/apache/spark/util/Utils.scala b/core/src/main/scala/org/apache/spark/util/Utils.scala
index fbbd436945ac..8b1ea4d25592 100644
--- a/core/src/main/scala/org/apache/spark/util/Utils.scala
+++ b/core/src/main/scala/org/apache/spark/util/Utils.scala
@@ -2302,7 +2302,7 @@ private[spark] object Utils
       case e: MultiException =>
         e.getThrowables.asScala.exists(isBindCollision)
       case e: NativeIoException =>
-        (e.getMessage != null && e.getMessage.startsWith("bind() failed: ")) ||
+        (e.getMessage != null && e.getMessage.matches("bind.*failed.*")) ||
           isBindCollision(e.getCause)
       case e: IOException =>
         (e.getMessage != null && e.getMessage.startsWith("Failed to bind to address")) ||
diff --git a/core/src/test/scala/org/apache/spark/rpc/netty/NettyRpcEnvSuite.scala b/core/src/test/scala/org/apache/spark/rpc/netty/NettyRpcEnvSuite.scala
index dce105d5e364..38081542ed1b 100644
--- a/core/src/test/scala/org/apache/spark/rpc/netty/NettyRpcEnvSuite.scala
+++ b/core/src/test/scala/org/apache/spark/rpc/netty/NettyRpcEnvSuite.scala
@@ -186,3 +186,9 @@ class SslNettyRpcEnvSuite extends NettyRpcEnvSuite with MockitoSugar with TimeLi
     SslTestUtils.updateWithSSLConfig(super.createSparkConf())
   }
 }
+
+class AutoNettyRpcEnvSuite extends NettyRpcEnvSuite with MockitoSugar with TimeLimits {
+  override def createSparkConf(): SparkConf = {
+    super.createSparkConf().set("spark.rpc.io.mode", "AUTO")
+  }
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org