You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zookeeper.apache.org by ca...@apache.org on 2011/11/15 19:28:39 UTC

svn commit: r1202358 - in /zookeeper/branches/branch-3.4: CHANGES.txt src/docs/src/documentation/content/xdocs/zookeeperAdmin.xml src/java/main/org/apache/zookeeper/server/persistence/FileTxnLog.java

Author: camille
Date: Tue Nov 15 18:28:38 2011
New Revision: 1202358

URL: http://svn.apache.org/viewvc?rev=1202358&view=rev
Log:
ZOOKEEPER-1239. add logging/stats to identify fsync stalls. (phunt via camille)

Modified:
    zookeeper/branches/branch-3.4/CHANGES.txt
    zookeeper/branches/branch-3.4/src/docs/src/documentation/content/xdocs/zookeeperAdmin.xml
    zookeeper/branches/branch-3.4/src/java/main/org/apache/zookeeper/server/persistence/FileTxnLog.java

Modified: zookeeper/branches/branch-3.4/CHANGES.txt
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/CHANGES.txt?rev=1202358&r1=1202357&r2=1202358&view=diff
==============================================================================
--- zookeeper/branches/branch-3.4/CHANGES.txt (original)
+++ zookeeper/branches/branch-3.4/CHANGES.txt Tue Nov 15 18:28:38 2011
@@ -375,6 +375,8 @@ BUGFIXES: 
 
   ZOOKEEPER-1208. Ephemeral node not removed after the client session is long gone. (phunt via camille)
   
+  ZOOKEEPER-1239. add logging/stats to identify fsync stalls. (phunt via camille)
+  
 IMPROVEMENTS:
   ZOOKEEPER-724. Improve junit test integration - log harness information 
   (phunt via mahadev)

Modified: zookeeper/branches/branch-3.4/src/docs/src/documentation/content/xdocs/zookeeperAdmin.xml
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/src/docs/src/documentation/content/xdocs/zookeeperAdmin.xml?rev=1202358&r1=1202357&r2=1202358&view=diff
==============================================================================
--- zookeeper/branches/branch-3.4/src/docs/src/documentation/content/xdocs/zookeeperAdmin.xml (original)
+++ zookeeper/branches/branch-3.4/src/docs/src/documentation/content/xdocs/zookeeperAdmin.xml Tue Nov 15 18:28:38 2011
@@ -783,6 +783,21 @@ server.3=zoo3:2888:3888</programlisting>
             </listitem>
            </varlistentry>
            
+           <varlistentry>
+             <term>fsync.warningthresholdms</term>
+             <listitem>
+               <para>(Java system property: <emphasis
+               role="bold">fsync.warningthresholdms</emphasis>)</para>
+
+               <para><emphasis role="bold">New in 3.3.4:</emphasis> A
+               warning message will be output to the log whenever an
+               fsync in the Transactional Log (WAL) takes longer than
+               this value. The values is specified in milliseconds and
+               defaults to 1000. This value can only be set as a
+               system property.</para>
+             </listitem>
+           </varlistentry>
+
           <varlistentry>
             <term>autopurge.snapRetainCount</term>
 

Modified: zookeeper/branches/branch-3.4/src/java/main/org/apache/zookeeper/server/persistence/FileTxnLog.java
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/src/java/main/org/apache/zookeeper/server/persistence/FileTxnLog.java?rev=1202358&r1=1202357&r2=1202358&view=diff
==============================================================================
--- zookeeper/branches/branch-3.4/src/java/main/org/apache/zookeeper/server/persistence/FileTxnLog.java (original)
+++ zookeeper/branches/branch-3.4/src/java/main/org/apache/zookeeper/server/persistence/FileTxnLog.java Tue Nov 15 18:28:38 2011
@@ -32,6 +32,7 @@ import java.nio.ByteBuffer;
 import java.util.ArrayList;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.concurrent.TimeUnit;
 import java.util.zip.Adler32;
 import java.util.zip.Checksum;
 
@@ -97,6 +98,9 @@ public class FileTxnLog implements TxnLo
 
     public final static int VERSION = 2;
 
+    /** Maximum time we allow for elapsed fsync before WARNing */
+    private final static long fsyncWarningThresholdMS;
+
     static {
         LOG = LoggerFactory.getLogger(FileTxnLog.class);
 
@@ -108,6 +112,7 @@ public class FileTxnLog implements TxnLo
                 LOG.warn(size + " is not a valid value for preAllocSize");
             }
         }
+        fsyncWarningThresholdMS = Long.getLong("fsync.warningthresholdms", 1000);
     }
 
     long lastZxidSeen;
@@ -307,7 +312,19 @@ public class FileTxnLog implements TxnLo
         for (FileOutputStream log : streamsToFlush) {
             log.flush();
             if (forceSync) {
+                long startSyncNS = System.nanoTime();
+
                 log.getChannel().force(false);
+
+                long syncElapsedMS =
+                    TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startSyncNS);
+                if (syncElapsedMS > fsyncWarningThresholdMS) {
+                    LOG.warn("fsync-ing the write ahead log in "
+                            + Thread.currentThread().getName()
+                            + " took " + syncElapsedMS
+                            + "ms which will adversely effect operation latency. "
+                            + "See the ZooKeeper troubleshooting guide");
+                }
             }
         }
         while (streamsToFlush.size() > 1) {