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

aryangupta1998 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 2c02f432d30 HDDS-12208. Give `ozone debug replicas verify` options for 
OM container location cache behavior. (#11015)
2c02f432d30 is described below

commit 2c02f432d3078ef6da65176aed031f7269d89f5c
Author: Aryan Gupta <[email protected]>
AuthorDate: Tue Aug 18 11:53:35 2026 +0530

    HDDS-12208. Give `ozone debug replicas verify` options for OM container 
location cache behavior. (#11015)
---
 .../docs/content/tools/debug/DebugReplicas.md      |  6 +++
 .../ozone/debug/replicas/ReplicasVerify.java       |  7 ++-
 .../ozone/debug/replicas/TestReplicasVerify.java   | 54 ++++++++++++++++++++++
 3 files changed, 66 insertions(+), 1 deletion(-)

diff --git a/hadoop-hdds/docs/content/tools/debug/DebugReplicas.md 
b/hadoop-hdds/docs/content/tools/debug/DebugReplicas.md
index 0072638cb37..66ca90d00fd 100644
--- a/hadoop-hdds/docs/content/tools/debug/DebugReplicas.md
+++ b/hadoop-hdds/docs/content/tools/debug/DebugReplicas.md
@@ -71,6 +71,7 @@ Verify data across replicas. There are multiple checks 
available, which can be s
 ```bash 
 Usage: ozone debug replicas verify [-hV] [--all-results] [--verbose]
                                    
[--container-cache-size=<containerCacheSize>]
+                                   [--refresh-from-scm]
                                     [-id=<scmServiceId>] [--scm=<scm>]
                                    ([--checksums] [--block-existence]
                                    [--container-state]) <uri>
@@ -109,6 +110,11 @@ failed checks.
       --container-state   Check the container and replica states. Containers in
                             [DELETING, DELETED] states, or it's replicas in
                             [DELETED, UNHEALTHY, INVALID] states fail the 
check.
+      --refresh-from-scm
+                          Force OM to refresh container locations from SCM
+                            before returning key info. This can slow down
+                            verification but may avoid stale location results
+                            from OM cache.
   -h, --help              Show this help message and exit.
       -id, --service-id=<scmServiceId>
                           ServiceId of SCM HA Cluster
diff --git 
a/hadoop-ozone/cli-debug/src/main/java/org/apache/hadoop/ozone/debug/replicas/ReplicasVerify.java
 
b/hadoop-ozone/cli-debug/src/main/java/org/apache/hadoop/ozone/debug/replicas/ReplicasVerify.java
index 44a8961f1b4..e886f945c34 100644
--- 
a/hadoop-ozone/cli-debug/src/main/java/org/apache/hadoop/ozone/debug/replicas/ReplicasVerify.java
+++ 
b/hadoop-ozone/cli-debug/src/main/java/org/apache/hadoop/ozone/debug/replicas/ReplicasVerify.java
@@ -82,6 +82,11 @@ public class ReplicasVerify extends Handler {
       description = "Print results for all passing and failing keys")
   private boolean allResults;
 
+  @CommandLine.Option(names = {"--refresh-from-scm"},
+      description = "Force OM to refresh container locations from SCM before 
returning key info. " +
+          "This can slow down verification but may avoid stale location 
results from OM cache.")
+  private boolean refreshContainerLocationsFromScm;
+
   @CommandLine.ArgGroup(exclusive = false, multiplicity = "1")
   private Verification verification;
 
@@ -334,7 +339,7 @@ void processKey(OzoneClient ozoneClient, String volumeName, 
String bucketName, S
       ArrayNode keysArray, AtomicBoolean allKeysPassed) throws IOException {
     keysProcessed.incrementAndGet();
     OmKeyInfo keyInfo = ozoneClient.getProxy().getKeyInfo(
-        volumeName, bucketName, keyName, false);
+        volumeName, bucketName, keyName, refreshContainerLocationsFromScm);
 
     // Check if key should be processed based on replication config
     if (!shouldProcessKeyByReplicationType(keyInfo)) {
diff --git 
a/hadoop-ozone/cli-debug/src/test/java/org/apache/hadoop/ozone/debug/replicas/TestReplicasVerify.java
 
b/hadoop-ozone/cli-debug/src/test/java/org/apache/hadoop/ozone/debug/replicas/TestReplicasVerify.java
new file mode 100644
index 00000000000..b42a0cf87b9
--- /dev/null
+++ 
b/hadoop-ozone/cli-debug/src/test/java/org/apache/hadoop/ozone/debug/replicas/TestReplicasVerify.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.ozone.debug.replicas;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.lang.reflect.Field;
+import org.junit.jupiter.api.Test;
+import picocli.CommandLine;
+
+/**
+ * Unit tests for replicas verify command option parsing.
+ */
+public class TestReplicasVerify {
+
+  @Test
+  void testRefreshContainerLocationsFromScmOption() throws Exception {
+    ReplicasVerify command = new ReplicasVerify();
+
+    new CommandLine(command).parseArgs("--checksums", "--refresh-from-scm", 
"/volume1");
+
+    assertThat(isRefreshContainerLocationsFromScmEnabled(command)).isTrue();
+  }
+
+  @Test
+  void testRefreshContainerLocationsFromScmDefault() throws Exception {
+    ReplicasVerify command = new ReplicasVerify();
+
+    new CommandLine(command).parseArgs("--checksums", "/volume1");
+
+    assertThat(isRefreshContainerLocationsFromScmEnabled(command)).isFalse();
+  }
+
+  private boolean isRefreshContainerLocationsFromScmEnabled(ReplicasVerify 
command) throws Exception {
+    Field field = 
ReplicasVerify.class.getDeclaredField("refreshContainerLocationsFromScm");
+    field.setAccessible(true);
+    return field.getBoolean(command);
+  }
+}


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

Reply via email to