[
https://issues.apache.org/jira/browse/KAFKA-14908?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18030039#comment-18030039
]
Keith Wall commented on KAFKA-14908:
------------------------------------
This issue went away for me, so I am happy if it is closed.
> 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
> Components: unit tests
> Reporter: Keith Wall
> Priority: Major
>
> 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)