[ 
https://issues.apache.org/jira/browse/KAFKA-1501?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14189472#comment-14189472
 ] 

Jay Kreps commented on KAFKA-1501:
----------------------------------

Interesting. There is an inherent race condition in between choosePorts picking 
an open port and then the test actually using it. We can't perfectly solve this 
issue (i.e. since our apache tests run on a shared unit test machine even if we 
are perfect it is possible we could get broken by other tests in another 
process). However choosePorts is particularly prone to the problem Ewan 
described because it will always return the same port until someone actually 
uses it. Another approach would be to chose the port randomly in some range, 
check that you can bind to it, and then release it and give it out. This would 
make this kind of accident less likely as you would have to both hit the race 
condition and collide on the same port.

> transient unit tests failures due to port already in use
> --------------------------------------------------------
>
>                 Key: KAFKA-1501
>                 URL: https://issues.apache.org/jira/browse/KAFKA-1501
>             Project: Kafka
>          Issue Type: Improvement
>          Components: core
>            Reporter: Jun Rao
>            Assignee: Guozhang Wang
>              Labels: newbie
>         Attachments: KAFKA-1501-choosePorts.patch, KAFKA-1501.patch, 
> KAFKA-1501.patch
>
>
> Saw the following transient failures.
> kafka.api.ProducerFailureHandlingTest > testTooLargeRecordWithAckOne FAILED
>     kafka.common.KafkaException: Socket server failed to bind to 
> localhost:59909: Address already in use.
>         at kafka.network.Acceptor.openServerSocket(SocketServer.scala:195)
>         at kafka.network.Acceptor.<init>(SocketServer.scala:141)
>         at kafka.network.SocketServer.startup(SocketServer.scala:68)
>         at kafka.server.KafkaServer.startup(KafkaServer.scala:95)
>         at kafka.utils.TestUtils$.createServer(TestUtils.scala:123)
>         at 
> kafka.api.ProducerFailureHandlingTest.setUp(ProducerFailureHandlingTest.scala:68)



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to