accumulo-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] ivakegg closed pull request #392: Fixes ACCUMULO-4832 WAL warnings
Date Tue, 27 Feb 2018 16:59:47 GMT
ivakegg closed pull request #392: Fixes ACCUMULO-4832 WAL warnings
URL: https://github.com/apache/accumulo/pull/392
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/fate/src/main/java/org/apache/accumulo/fate/zookeeper/Retry.java b/fate/src/main/java/org/apache/accumulo/fate/zookeeper/Retry.java
index d710e2cb8b..73d5227a14 100644
--- a/fate/src/main/java/org/apache/accumulo/fate/zookeeper/Retry.java
+++ b/fate/src/main/java/org/apache/accumulo/fate/zookeeper/Retry.java
@@ -32,7 +32,8 @@
   private long maxRetries, maxWait, waitIncrement;
   private long retriesDone, currentWait;
 
-  private long logInterval;
+  private static long NANO_SEC_PER_MILLI_SEC = 1000000L;
+  private long logIntervalNanoSec;
   private long lastRetryLog;
 
   /**
@@ -54,7 +55,7 @@ public Retry(long maxRetries, long startWait, long waitIncrement, long maxWait,
     this.waitIncrement = waitIncrement;
     this.retriesDone = 0l;
     this.currentWait = startWait;
-    this.logInterval = logInterval;
+    this.logIntervalNanoSec = (logInterval * NANO_SEC_PER_MILLI_SEC);
     this.lastRetryLog = -1;
   }
 
@@ -126,11 +127,11 @@ public boolean isMaxRetryDisabled() {
 
   // Visible for testing
   void setLogInterval(long logInterval) {
-    this.logInterval = logInterval;
+    this.logIntervalNanoSec = logInterval * NANO_SEC_PER_MILLI_SEC;
   }
 
   public long getLogInterval() {
-    return logInterval;
+    return logIntervalNanoSec / NANO_SEC_PER_MILLI_SEC;
   }
 
   public boolean canRetry() {
@@ -166,23 +167,47 @@ protected void sleep(long wait) throws InterruptedException {
   }
 
   public void logRetry(Logger log, String message, Throwable t) {
-    // log the first time, and then after every logInterval
-    if (lastRetryLog < 0 || (System.currentTimeMillis() - lastRetryLog) > logInterval)
{
+    // log the first time as debug, and then after every logInterval as a warning
+    long now = System.nanoTime();
+    if (lastRetryLog < 0) {
+      if (log.isDebugEnabled()) {
+        log.debug(getMessage(message, t));
+      }
+      lastRetryLog = now;
+    } else if ((now - lastRetryLog) > logIntervalNanoSec) {
       log.warn(getMessage(message), t);
-      lastRetryLog = System.currentTimeMillis();
+      lastRetryLog = now;
+    } else {
+      if (log.isTraceEnabled()) {
+        log.trace(getMessage(message, t));
+      }
     }
   }
 
   public void logRetry(Logger log, String message) {
-    // log the first time, and then after every logInterval
-    if (lastRetryLog < 0 || (System.currentTimeMillis() - lastRetryLog) > logInterval)
{
+    // log the first time as debug, and then after every logInterval as a warning
+    long now = System.nanoTime();
+    if (lastRetryLog < 0) {
+      if (log.isDebugEnabled()) {
+        log.debug(getMessage(message));
+      }
+      lastRetryLog = now;
+    } else if ((now - lastRetryLog) > logIntervalNanoSec) {
       log.warn(getMessage(message));
-      lastRetryLog = System.currentTimeMillis();
+      lastRetryLog = now;
+    } else {
+      if (log.isTraceEnabled()) {
+        log.trace(getMessage(message));
+      }
     }
   }
 
   private String getMessage(String message) {
-    return message + ", retrying attempt " + (retriesDone + 1) + " (suppressing retry messages
for " + logInterval + "ms)";
+    return message + ", retrying attempt " + (retriesDone + 1) + " (suppressing retry messages
for " + getLogInterval() + "ms)";
+  }
+
+  private String getMessage(String message, Throwable t) {
+    return message + ":" + t + ", retrying attempt " + (retriesDone + 1) + " (suppressing
retry messages for " + getLogInterval() + "ms)";
   }
 
 }
diff --git a/fate/src/test/java/org/apache/accumulo/fate/zookeeper/RetryTest.java b/fate/src/test/java/org/apache/accumulo/fate/zookeeper/RetryTest.java
index fddef47ea6..bca4e97a82 100644
--- a/fate/src/test/java/org/apache/accumulo/fate/zookeeper/RetryTest.java
+++ b/fate/src/test/java/org/apache/accumulo/fate/zookeeper/RetryTest.java
@@ -152,8 +152,14 @@ public void testUnlimitedRetry() {
   @Test
   public void testLogging() {
     Logger testLogger = EasyMock.createMock(Logger.class);
+    EasyMock.expect(testLogger.isDebugEnabled()).andReturn(true);
+    testLogger.debug(EasyMock.anyObject(String.class));
+    EasyMock.expectLastCall().times(1);
+    EasyMock.expect(testLogger.isTraceEnabled()).andReturn(true).anyTimes();
+    testLogger.trace(EasyMock.anyObject(String.class));
+    EasyMock.expectLastCall().anyTimes();
     testLogger.warn(EasyMock.anyObject(String.class));
-    EasyMock.expectLastCall().times(4, 6);
+    EasyMock.expectLastCall().times(3, 5);
     EasyMock.replay(testLogger);
 
     // we want to do this for 5 second and observe the log messages
diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/log/TabletServerLogger.java
b/server/tserver/src/main/java/org/apache/accumulo/tserver/log/TabletServerLogger.java
index 3843210b3a..1b180a2a9c 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/log/TabletServerLogger.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/log/TabletServerLogger.java
@@ -338,10 +338,9 @@ private void write(final Collection<CommitSession> sessions, boolean
mincFinish,
           success = (currentLogSet == logSetId.get());
         }
       } catch (DfsLogger.LogClosedException ex) {
-        writeRetry.logRetry(log, "Logs closed while writing");
+        writeRetry.logRetry(log, "Logs closed while writing", ex);
       } catch (Exception t) {
-        if (writeRetry.retriesCompleted() != 0)
-          writeRetry.logRetry(log, "Failed to write to WAL", t);
+        writeRetry.logRetry(log, "Failed to write to WAL", t);
 
         try {
           // Backoff


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message