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

weichiu pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git


The following commit(s) were added to refs/heads/trunk by this push:
     new caf8af0de3e HDFS-17768. Observer namenode network delay causing empty 
block location for getBatchedListing (#7593)
caf8af0de3e is described below

commit caf8af0de3e63ba8423760582bc640d51f0d558b
Author: Dimas Shidqi Parikesit <dimasparikes...@gmail.com>
AuthorDate: Wed Apr 16 20:27:43 2025 -0400

    HDFS-17768. Observer namenode network delay causing empty block location 
for getBatchedListing (#7593)
---
 .../apache/hadoop/hdfs/server/namenode/FSNamesystem.java    | 13 +++++++++++++
 .../hadoop/hdfs/server/namenode/ha/TestObserverNode.java    |  3 +++
 2 files changed, 16 insertions(+)

diff --git 
a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
 
b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
index e7b1b7e1d69..f359d86df7b 100644
--- 
a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
+++ 
b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
@@ -4325,11 +4325,22 @@ BatchedDirectoryListing getBatchedListing(String[] 
srcs, byte[] startAfter,
           if (dirListing == null) {
             throw new FileNotFoundException("Path " + src + " does not exist");
           }
+          if (needLocation && isObserver()) {
+            for (HdfsFileStatus fs : dirListing.getPartialListing()) {
+              if (fs instanceof HdfsLocatedFileStatus) {
+                LocatedBlocks lbs = ((HdfsLocatedFileStatus) 
fs).getLocatedBlocks();
+                checkBlockLocationsWhenObserver(lbs, fs.toString());
+              }
+            }
+          }
           listing = new HdfsPartialListing(
               srcsIndex, Lists.newArrayList(dirListing.getPartialListing()));
           numEntries += listing.getPartialListing().size();
           lastListing = dirListing;
         } catch (Exception e) {
+          if (e instanceof ObserverRetryOnActiveException) {
+            throw (ObserverRetryOnActiveException) e;
+          }
           if (e instanceof AccessControlException) {
             logAuditEvent(false, operationName, src);
           }
@@ -4392,6 +4403,8 @@ BatchedDirectoryListing getBatchedListing(String[] srcs, 
byte[] startAfter,
             true,
             returnedStartAfter);
       }
+    } catch(ObserverRetryOnActiveException e){
+      throw e;
     } finally {
       readUnlock(RwLockMode.FS, operationName,
           getLockReportInfoSupplier(Arrays.toString(srcs)));
diff --git 
a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestObserverNode.java
 
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestObserverNode.java
index 55d17d3bb27..0111f273e71 100644
--- 
a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestObserverNode.java
+++ 
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestObserverNode.java
@@ -480,6 +480,9 @@ public void testObserverNodeBlockMissingRetry() throws 
Exception {
     dfs.getClient().getLocatedFileInfo(testPath.toString(), false);
     assertSentTo(0);
 
+    dfs.getClient().batchedListPaths(new String[]{"/"}, new byte[0], true);
+    assertSentTo(0);
+
     Mockito.reset(bmSpy);
   }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-commits-h...@hadoop.apache.org

Reply via email to