You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "Luke Chen (Jira)" <ji...@apache.org> on 2023/04/19 03:00:00 UTC

[jira] [Resolved] (KAFKA-14908) Sporadic "Address already in use" when starting kafka cluster embedded within tests

     [ https://issues.apache.org/jira/browse/KAFKA-14908?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Luke Chen resolved KAFKA-14908.
-------------------------------
    Fix Version/s: 3.6.0
       Resolution: Fixed

> Sporadic "Address already in use" when starting kafka cluster embedded within tests
> -----------------------------------------------------------------------------------
>
>                 Key: KAFKA-14908
>                 URL: https://issues.apache.org/jira/browse/KAFKA-14908
>             Project: Kafka
>          Issue Type: Bug
>            Reporter: Keith Wall
>            Priority: Minor
>             Fix For: 3.6.0
>
>
> We have an integration test suite that starts/stops a kafka cluster before/after each test.   Kafka is being started programmatically within the same JVM that is running the tests.
> Sometimes we get sporadic failures from with Kafka as it tries to bind the server socket.
> {code:java}
> org.apache.kafka.common.KafkaException: Socket server failed to bind to 0.0.0.0:9092: Address already in use.
>     at kafka.network.Acceptor.openServerSocket(SocketServer.scala:684)
>     at kafka.network.Acceptor.<init>(SocketServer.scala:576)
>     at kafka.network.DataPlaneAcceptor.<init>(SocketServer.scala:433)
>     at kafka.network.SocketServer.createDataPlaneAcceptor(SocketServer.scala:247)
>     at kafka.network.SocketServer.createDataPlaneAcceptorAndProcessors(SocketServer.scala:226)
>     at kafka.network.SocketServer.$anonfun$new$31(SocketServer.scala:173)
>     at kafka.network.SocketServer.$anonfun$new$31$adapted(SocketServer.scala:173)
>     at scala.collection.IterableOnceOps.foreach(IterableOnce.scala:575)
>     at scala.collection.IterableOnceOps.foreach$(IterableOnce.scala:573)
>     at scala.collection.AbstractIterable.foreach(Iterable.scala:933)
>     at kafka.network.SocketServer.<init>(SocketServer.scala:173)
>     at kafka.server.KafkaServer.startup(KafkaServer.scala:331) {code}
> Investigation has shown that the socket is in the timed_wait state from a previous test.
> I know Kafka supports ephemeral ports, but this isn't convenient to our use-case.  
> I'd like to suggest that Kafka is changed to set the SO_REUSEADDR on the server socket.  I believe this is standard practice for server applications that run on well known ports .
> I don't believe this change would introduce a backward compatibility concerns. 
>  
> I will open a PR so that can be considered. Thank you.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)