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

ivandika pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new f0b285d0bb1 HDDS-13658. Limit Snapshot Cache size warning logs. (#9035)
f0b285d0bb1 is described below

commit f0b285d0bb16f76cf60ee0b3a43259058d8704e1
Author: Sadanand Shenoy <[email protected]>
AuthorDate: Tue Sep 16 19:59:21 2025 +0530

    HDDS-13658. Limit Snapshot Cache size warning logs. (#9035)
---
 .../hadoop/ozone/om/snapshot/SnapshotCache.java      | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git 
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/SnapshotCache.java
 
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/SnapshotCache.java
index eedf18f6534..d48ab12c9f1 100644
--- 
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/SnapshotCache.java
+++ 
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/SnapshotCache.java
@@ -38,6 +38,8 @@
 import org.apache.hadoop.ozone.om.exceptions.OMException;
 import org.apache.hadoop.ozone.om.lock.IOzoneManagerLock;
 import org.apache.hadoop.ozone.om.lock.OMLockDetails;
+import org.apache.ratis.util.BatchLogger;
+import org.apache.ratis.util.TimeDuration;
 import org.apache.ratis.util.function.UncheckedAutoCloseableSupplier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -48,6 +50,7 @@
 public class SnapshotCache implements ReferenceCountedCallback, AutoCloseable {
 
   static final Logger LOG = LoggerFactory.getLogger(SnapshotCache.class);
+  private static final long CACHE_WARNING_THROTTLE_INTERVAL_MS = 60_000L;
 
   // Snapshot cache internal hash map.
   // Key:   SnapshotId
@@ -69,6 +72,15 @@ public class SnapshotCache implements 
ReferenceCountedCallback, AutoCloseable {
 
   private final OMMetrics omMetrics;
 
+  private enum BatchLogKey implements BatchLogger.Key {
+    SNAPSHOT_CACHE_SIZE_EXCEEDED;
+
+    @Override
+    public TimeDuration getBatchDuration() {
+      return TimeDuration.valueOf(CACHE_WARNING_THROTTLE_INTERVAL_MS, 
TimeUnit.MILLISECONDS);
+    }
+  }
+
   private boolean shouldCompactTable(String tableName) {
     return !COLUMN_FAMILIES_TO_TRACK_IN_DAG.contains(tableName);
   }
@@ -188,8 +200,12 @@ public enum Reason {
   public UncheckedAutoCloseableSupplier<OmSnapshot> get(UUID key) throws 
IOException {
     // Warn if actual cache size exceeds the soft limit already.
     if (size() > cacheSizeLimit) {
-      LOG.warn("Snapshot cache size ({}) exceeds configured soft-limit ({}).",
-          size(), cacheSizeLimit);
+      BatchLogger.print(
+          BatchLogKey.SNAPSHOT_CACHE_SIZE_EXCEEDED, // The unique key for this 
log type
+          "CacheSizeWarning", // A specific name for this log message
+          suffix -> LOG.warn("Snapshot cache size ({}) exceeds configured 
soft-limit ({}).{}",
+              size(), cacheSizeLimit, suffix)
+      );
     }
     OMLockDetails lockDetails = lock.acquireReadLock(SNAPSHOT_DB_LOCK, 
key.toString());
     if (!lockDetails.isLockAcquired()) {


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to