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

ddanielr 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 46c1a2819f Fixes bug where monitor appender does not notice monitor 
died (#5972)
46c1a2819f is described below

commit 46c1a2819f01054f77ce4d3611c461f1f9453bb5
Author: Keith Turner <[email protected]>
AuthorDate: Mon Nov 10 11:58:56 2025 -0500

    Fixes bug where monitor appender does not notice monitor died (#5972)
    
    When the monitor process died the monitor appender did not notice
    because it kept using the same stat which does not change on absence.
    Also reusing the stat object may not be thread safe.  Made the stat
    object a thread local to avoid object allocation and use by multiple
    threads.
---
 .../java/org/apache/accumulo/core/fate/zookeeper/ZooCache.java   | 5 +++++
 .../accumulo/monitor/util/logging/AccumuloMonitorAppender.java   | 9 ++++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git 
a/core/src/main/java/org/apache/accumulo/core/fate/zookeeper/ZooCache.java 
b/core/src/main/java/org/apache/accumulo/core/fate/zookeeper/ZooCache.java
index d7f924f576..1c380de231 100644
--- a/core/src/main/java/org/apache/accumulo/core/fate/zookeeper/ZooCache.java
+++ b/core/src/main/java/org/apache/accumulo/core/fate/zookeeper/ZooCache.java
@@ -82,6 +82,11 @@ public class ZooCache {
       return ephemeralOwner;
     }
 
+    public void clear() {
+      this.ephemeralOwner = 0;
+      this.mzxid = 0;
+    }
+
     private void set(ZcStat cachedStat) {
       this.ephemeralOwner = cachedStat.ephemeralOwner;
       this.mzxid = cachedStat.mzxid;
diff --git 
a/server/monitor/src/main/java/org/apache/accumulo/monitor/util/logging/AccumuloMonitorAppender.java
 
b/server/monitor/src/main/java/org/apache/accumulo/monitor/util/logging/AccumuloMonitorAppender.java
index f6f575eac0..a4419968e5 100644
--- 
a/server/monitor/src/main/java/org/apache/accumulo/monitor/util/logging/AccumuloMonitorAppender.java
+++ 
b/server/monitor/src/main/java/org/apache/accumulo/monitor/util/logging/AccumuloMonitorAppender.java
@@ -146,7 +146,9 @@ public class AccumuloMonitorAppender extends 
AbstractAppender {
     this.queueSize = queueSize;
     this.async = async;
 
-    final var stat = new ZcStat();
+    // Avoids object allocations in the lambda
+    ThreadLocal<ZcStat> threadLocalStat = ThreadLocal.withInitial(ZcStat::new);
+
     this.monitorLocator = () -> {
       // lazily set up context/path
       if (context == null) {
@@ -154,7 +156,12 @@ public class AccumuloMonitorAppender extends 
AbstractAppender {
         path = context.getZooKeeperRoot() + Constants.ZMONITOR_HTTP_ADDR;
       }
       // get the current location from the cache
+      var stat = threadLocalStat.get();
+      stat.clear();
       byte[] loc = context.getZooCache().get(path, stat);
+      if (loc == null) {
+        return Optional.empty();
+      }
       Pair<Long,Optional<URI>> last = lastResult;
       if (stat.getMzxid() != last.getFirst()) {
         // only create new objects if there's a change

Reply via email to