一、问题描述:
最近使用storm之后发现zookeeper总是出现警告,故此跟踪了一下源码,知道问题产生在哪里。警告信息如下:
2014-09-19 13:41:29,400 [myid:1] - WARN [SyncThread:1:FileTxnLog@321] - fsync-ing the write ahead log in SyncThread:1 took 4575ms which will adversely effect operation latency. See the ZooKeeper troubleshooting guide
2014-09-19 13:41:30,453 [myid:1] - WARN [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:Follower@89] - Exception when following the leader
java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:129)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
at java.io.BufferedInputStream.read(BufferedInputStream.java:237)
at java.io.DataInputStream.readInt(DataInputStream.java:370)
at org.apache.jute.BinaryInputArchive.readInt(BinaryInputArchive.java:63)
二、问题定位:(FileTxnLog)
org.apache.zookeeper.server.persistence.FileTxnLog$FileTxnIterator.class

/**
* commit the logs. make sure that evertyhing hits the
* disk
*/
public synchronized void commit() throws IOException {
if (logStream != null) {
logStream.flush();
}
for (FileOutputStream log : streamsToFlush) {
log.flush();
if (forceSync) {
long startSyncNS = System.nanoTime();

本文主要分析了Zookeeper 3.4.6中因fsync操作导致的警告问题。通过研究源码,定位到fsync.WarningThresholdMS的默认值为1000ms,当fsync时间超过这个阈值时,会发出警告。文中还探讨了解决方案,即在`java.env`配置文件中设置系统属性`fsync.warningthresholdms`以延长警告阈值。
最低0.47元/天 解锁文章
1207

被折叠的 条评论
为什么被折叠?



