Skip to content

Commit 8eb2211

Browse files
dParikesitjojochuang
authored andcommitted
HDFS-17768. Observer namenode network delay causing empty block location for getBatchedListing (#7593)
(cherry picked from commit caf8af0)
1 parent c293424 commit 8eb2211

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4284,11 +4284,22 @@ BatchedDirectoryListing getBatchedListing(String[] srcs, byte[] startAfter,
42844284
if (dirListing == null) {
42854285
throw new FileNotFoundException("Path " + src + " does not exist");
42864286
}
4287+
if (needLocation && isObserver()) {
4288+
for (HdfsFileStatus fs : dirListing.getPartialListing()) {
4289+
if (fs instanceof HdfsLocatedFileStatus) {
4290+
LocatedBlocks lbs = ((HdfsLocatedFileStatus) fs).getLocatedBlocks();
4291+
checkBlockLocationsWhenObserver(lbs, fs.toString());
4292+
}
4293+
}
4294+
}
42874295
listing = new HdfsPartialListing(
42884296
srcsIndex, Lists.newArrayList(dirListing.getPartialListing()));
42894297
numEntries += listing.getPartialListing().size();
42904298
lastListing = dirListing;
42914299
} catch (Exception e) {
4300+
if (e instanceof ObserverRetryOnActiveException) {
4301+
throw (ObserverRetryOnActiveException) e;
4302+
}
42924303
if (e instanceof AccessControlException) {
42934304
logAuditEvent(false, operationName, src);
42944305
}
@@ -4351,6 +4362,8 @@ BatchedDirectoryListing getBatchedListing(String[] srcs, byte[] startAfter,
43514362
true,
43524363
returnedStartAfter);
43534364
}
4365+
} catch(ObserverRetryOnActiveException e){
4366+
throw e;
43544367
} finally {
43554368
readUnlock(operationName,
43564369
getLockReportInfoSupplier(Arrays.toString(srcs)));

hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestObserverNode.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,9 @@ public void testObserverNodeBlockMissingRetry() throws Exception {
480480
dfs.getClient().getLocatedFileInfo(testPath.toString(), false);
481481
assertSentTo(0);
482482

483+
dfs.getClient().batchedListPaths(new String[]{"/"}, new byte[0], true);
484+
assertSentTo(0);
485+
483486
Mockito.reset(bmSpy);
484487
}
485488

0 commit comments

Comments
 (0)