This is an automated email from the ASF dual-hosted git repository.

ctubbsii pushed a commit to branch 2.1
in repository https://gitbox.apache.org/repos/asf/accumulo.git


The following commit(s) were added to refs/heads/2.1 by this push:
     new 763ab0fb04 Fix issues on monitor with GC status (#3403)
763ab0fb04 is described below

commit 763ab0fb04005b5232140d5980c1c5c6e635d478
Author: Christopher Tubbs <ctubb...@apache.org>
AuthorDate: Thu May 18 10:21:51 2023 -0400

    Fix issues on monitor with GC status (#3403)
    
    * Always set the finished time for GC cycles, even if an exception
      occurred in the cycle. This prevents a GCStatus object containing
      a started time, but the finished time staying the default value of
      0, and ensures the current GC cycle that failed is rolled into the
      last GC cycle.
    * Add start time to monitor for GC cycles, and show when a cycle
      is in a Waiting or Running state.
    
    This fixes #3374
---
 .../accumulo/gc/GarbageCollectWriteAheadLogs.java  |  8 +++----
 .../apache/accumulo/gc/SimpleGarbageCollector.java |  8 +++----
 .../monitor/rest/gc/GarbageCollectorStats.java     |  4 +++-
 .../org/apache/accumulo/monitor/resources/js/gc.js | 27 +++++++++++++++++++---
 .../org/apache/accumulo/monitor/templates/gc.ftl   |  3 ++-
 5 files changed, 37 insertions(+), 13 deletions(-)

diff --git 
a/server/gc/src/main/java/org/apache/accumulo/gc/GarbageCollectWriteAheadLogs.java
 
b/server/gc/src/main/java/org/apache/accumulo/gc/GarbageCollectWriteAheadLogs.java
index 75c294c519..ecfaeaba66 100644
--- 
a/server/gc/src/main/java/org/apache/accumulo/gc/GarbageCollectWriteAheadLogs.java
+++ 
b/server/gc/src/main/java/org/apache/accumulo/gc/GarbageCollectWriteAheadLogs.java
@@ -217,12 +217,12 @@ public class GarbageCollectWriteAheadLogs {
         span5.end();
       }
 
-      status.currentLog.finished = removeStop;
-      status.lastLog = status.currentLog;
-      status.currentLog = new GcCycleStats();
-
     } catch (Exception e) {
       log.error("exception occurred while garbage collecting write ahead 
logs", e);
+    } finally {
+      status.currentLog.finished = System.currentTimeMillis();
+      status.lastLog = status.currentLog;
+      status.currentLog = new GcCycleStats();
     }
   }
 
diff --git 
a/server/gc/src/main/java/org/apache/accumulo/gc/SimpleGarbageCollector.java 
b/server/gc/src/main/java/org/apache/accumulo/gc/SimpleGarbageCollector.java
index 62ce126b8a..314dc2baf6 100644
--- a/server/gc/src/main/java/org/apache/accumulo/gc/SimpleGarbageCollector.java
+++ b/server/gc/src/main/java/org/apache/accumulo/gc/SimpleGarbageCollector.java
@@ -223,14 +223,14 @@ public class SimpleGarbageCollector extends 
AbstractServer implements Iface {
             incrementStatsForRun(userGC);
             logStats();
 
+          } catch (Exception e) {
+            TraceUtil.setException(innerSpan, e, false);
+            log.error("{}", e.getMessage(), e);
+          } finally {
             status.current.finished = System.currentTimeMillis();
             status.last = status.current;
             gcCycleMetrics.setLastCollect(status.current);
             status.current = new GcCycleStats();
-
-          } catch (Exception e) {
-            TraceUtil.setException(innerSpan, e, false);
-            log.error("{}", e.getMessage(), e);
           }
 
           final long tStop = System.nanoTime();
diff --git 
a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/gc/GarbageCollectorStats.java
 
b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/gc/GarbageCollectorStats.java
index 2f4afb4409..5ee7f3d215 100644
--- 
a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/gc/GarbageCollectorStats.java
+++ 
b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/gc/GarbageCollectorStats.java
@@ -32,6 +32,7 @@ public class GarbageCollectorStats {
 
   // Variable names become JSON key
   public final String type;
+  public final long started;
   public final long finished;
   public final long candidates;
   public final long inUse;
@@ -47,11 +48,12 @@ public class GarbageCollectorStats {
   public GarbageCollectorStats(String type, GcCycleStats thriftStats) {
     log.info("Creating {} stats using thriftStats = {}", type, thriftStats);
     this.type = type;
+    this.started = thriftStats.started;
     this.finished = thriftStats.finished;
     this.candidates = thriftStats.candidates;
     this.inUse = thriftStats.inUse;
     this.deleted = thriftStats.deleted;
     this.errors = thriftStats.errors;
-    this.duration = this.finished - thriftStats.started;
+    this.duration = thriftStats.finished - thriftStats.started;
   }
 }
diff --git 
a/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/gc.js
 
b/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/gc.js
index 9add5ca1d6..6b1a8d4119 100644
--- 
a/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/gc.js
+++ 
b/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/gc.js
@@ -32,16 +32,34 @@ $(document).ready(function () {
     "stateSave": true,
     "dom": 't<"align-left"l>p',
     "columnDefs": [{
-        "targets": "date",
+        "targets": "dateStarted",
         "render": function (data, type, row) {
-          if (type === 'display' && data > 0) data = dateFormat(data);
+          if (type === 'display') {
+            if (data === 0) data = 'Waiting';
+            else if (data > 0) data = dateFormat(data);
+            else data = 'Error';
+          }
+          return data;
+        }
+      },
+      {
+        "targets": "dateFinished",
+        "render": function (data, type, row) {
+          if (type === 'display') {
+            if (data === 0) data = '&mdash;';
+            else if (data > 0) data = dateFormat(data);
+            else data = 'Error';
+          }
           return data;
         }
       },
       {
         "targets": "duration",
         "render": function (data, type, row) {
-          if (type === 'display') data = timeDuration(data);
+          if (type === 'display') {
+            if (data < 0) data = "Running";
+            else data = timeDuration(data);
+          }
           return data;
         }
       },
@@ -56,6 +74,9 @@ $(document).ready(function () {
     "columns": [{
         "data": "type"
       },
+      {
+        "data": "started"
+      },
       {
         "data": "finished"
       },
diff --git 
a/server/monitor/src/main/resources/org/apache/accumulo/monitor/templates/gc.ftl
 
b/server/monitor/src/main/resources/org/apache/accumulo/monitor/templates/gc.ftl
index 395f8fc436..dcb10ec38c 100644
--- 
a/server/monitor/src/main/resources/org/apache/accumulo/monitor/templates/gc.ftl
+++ 
b/server/monitor/src/main/resources/org/apache/accumulo/monitor/templates/gc.ftl
@@ -30,7 +30,8 @@
           <thead>
             <tr>
               <th class="firstcell">Activity&nbsp;</th>
-              <th class="date">Finished&nbsp;</th>
+              <th class="dateStarted">Started&nbsp;</th>
+              <th class="dateFinished">Finished&nbsp;</th>
               <th class="big-num">Candidates&nbsp;</th>
               <th class="big-num">Deleted&nbsp;</th>
               <th class="big-num">In&nbsp;Use&nbsp;</th>

Reply via email to