kafkaserver shutdown无限期挂起单元测试(kafka从0.8.1.1升级到0.8.2.0)

时间:2015-02-12 19:47:35

标签: java apache-zookeeper apache-kafka

我们最近从kafka 0.8.1.1升级到0.8.2.0。我们的集成测试失败,因为测试无限期地挂在kafkaServer.shutdown()上

这些是我的经纪人设置

Properties brokerProps = new Properties();
brokerProps.put("zookeeper.connect", "127.0.0.1:8888");
brokerProps.put("port", "9092");
brokerProps.setProperty("num.partitions", "10");
brokerProps.setProperty("broker.id", "1");
brokerProps.setProperty("log.dirs", "some log dir");
brokerProps.setProperty("advertised.host.name", "127.0.0.1");
KafkaConfig config = new KafkaConfig(brokerProps);

这是我看到的堆栈跟踪

 ERROR [kafka-network-thread-9092-0] kafka.network.Processor - Closing socket for /127.0.0.1 because of error
java.io.IOException: Broken pipe
    at sun.nio.ch.FileDispatcherImpl.write0(Native Method) ~[na:1.8.0_25]
    at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47) ~[na:1.8.0_25]
    at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93) ~[na:1.8.0_25]
    at sun.nio.ch.IOUtil.write(IOUtil.java:65) ~[na:1.8.0_25]
    at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:470) ~[na:1.8.0_25]
    at kafka.api.PartitionDataSend.writeTo(FetchResponse.scala:68) ~[kafka_2.10-0.8.2.0.jar:na]
    at kafka.network.MultiSend.writeTo(Transmission.scala:101) ~[kafka_2.10-0.8.2.0.jar:na]
    at kafka.api.TopicDataSend.writeTo(FetchResponse.scala:125) ~[kafka_2.10-0.8.2.0.jar:na]
    at kafka.network.MultiSend.writeTo(Transmission.scala:101) ~[kafka_2.10-0.8.2.0.jar:na]
    at kafka.api.FetchResponseSend.writeTo(FetchResponse.scala:231) ~[kafka_2.10-0.8.2.0.jar:na]
    at kafka.network.Processor.write(SocketServer.scala:472) ~[kafka_2.10-0.8.2.0.jar:na]
    at kafka.network.Processor.run(SocketServer.scala:342) ~[kafka_2.10-0.8.2.0.jar:na]
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_25]

2 个答案:

答案 0 :(得分:2)

发现问题所在。我们在关闭kafkaserver之前关闭了ZK。 KafkaServer无限期地等待尝试连接到zkClient。    改变订单有效。

答案 1 :(得分:0)

使用jstack创建一个threaddump并分析输出。查找被阻塞的线程或可运行的线程,这些线程在本机调用中,如套接字或文件操作。然后检查有问题的线程的源代码。