ZooKeeper日志中有这么多“Broken pipe IOE”

时间:2014-09-17 03:02:14

标签: java sockets exception apache-zookeeper

任何人都可以帮忙解释为什么我在ZooKeeper日志中获得了如此多的“Broken pipe IOE”吗?

ZooKeeper几乎每分钟都会抛出此异常。我不认为我们经常使用四字母命令dumpWatches。那是什么意思呢?

这可能是由命令wchc引起的,因为我们的ZooKeeper有超过一万个znode。我发现此命令是从具有不同端口的同一服务器执行的。 ZooKeeper会经常调用此命令吗?

    2014-09-17,10:52:09,179 ERROR org.apache.zookeeper.server.NIOServerCnxn: [myid:0] Error sending data synchronously
    java.io.IOException: Broken pipe
            at sun.nio.ch.FileDispatcher.write0(Native Method)
            at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:29)
            at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:69)
            at sun.nio.ch.IOUtil.write(IOUtil.java:40)
            at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:336)
            at org.apache.zookeeper.server.NIOServerCnxn.sendBufferSync(NIOServerCnxn.java:138)
            at org.apache.zookeeper.server.NIOServerCnxn$SendBufferWriter.checkFlush(NIOServerCnxn.java:453)
            at org.apache.zookeeper.server.NIOServerCnxn$SendBufferWriter.write(NIOServerCnxn.java:474)
            at java.io.BufferedWriter.flushBuffer(BufferedWriter.java:111)
            at java.io.BufferedWriter.write(BufferedWriter.java:212)
            at java.io.PrintWriter.write(PrintWriter.java:412)
            at java.io.PrintWriter.write(PrintWriter.java:429)
            at java.io.PrintWriter.print(PrintWriter.java:559)
            at java.io.PrintWriter.println(PrintWriter.java:695)
            at org.apache.zookeeper.server.WatchManager.dumpWatches(WatchManager.java:166)
            at org.apache.zookeeper.server.DataTree.dumpWatches(DataTree.java:1240)
            at org.apache.zookeeper.server.NIOServerCnxn$WatchCommand.commandRun(NIOServerCnxn.java:722)
            at org.apache.zookeeper.server.NIOServerCnxn$CommandThread.run(NIOServerCnxn.java:496)
    2014-09-17,10:52:09,179 INFO org.apache.zookeeper.server.NIOServerCnxn: [myid:0] Closed socket connection for client /10.20.201.234:53756 which had sessionid 0x34840357f664081
    2014-09-17,10:52:09,179 ERROR org.apache.zookeeper.server.NIOServerCnxn: [myid:0] Error sending data synchronously
    java.io.IOException: Broken pipe
            at sun.nio.ch.FileDispatcher.write0(Native Method)
            at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:29)
            at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:69)
            at sun.nio.ch.IOUtil.write(IOUtil.java:40)
            at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:336)
            at org.apache.zookeeper.server.NIOServerCnxn.sendBufferSync(NIOServerCnxn.java:138)
            at org.apache.zookeeper.server.NIOServerCnxn$SendBufferWriter.checkFlush(NIOServerCnxn.java:453)
            at org.apache.zookeeper.server.NIOServerCnxn$SendBufferWriter.write(NIOServerCnxn.java:474)
            at java.io.BufferedWriter.flushBuffer(BufferedWriter.java:111)
            at java.io.BufferedWriter.flush(BufferedWriter.java:235)
            at java.io.PrintWriter.flush(PrintWriter.java:276)
            at org.apache.zookeeper.server.NIOServerCnxn.cleanupWriterSocket(NIOServerCnxn.java:424)
            at org.apache.zookeeper.server.NIOServerCnxn.access$000(NIOServerCnxn.java:60)
            at org.apache.zookeeper.server.NIOServerCnxn$CommandThread.run(NIOServerCnxn.java:500)

1 个答案:

答案 0 :(得分:0)

我找到了原因。我们使用TaoKeeper来监控ZooKeeper的状态。它会定期发送wchc和其他命令来检查状态。当ZooKeeper收到wchc时,会发生异常,因为我们有太多的znode。

我认为TaoKeeper应该使用mntr而不是wchc,这可能会影响ZooKeeper在拥有大量znode时的性能。