Skip to content

Commit caf8af0

Browse files
authored
HDFS-17768. Observer namenode network delay causing empty block location for getBatchedListing (#7593)
1 parent 3aaba94 commit caf8af0

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
@@ -4325,11 +4325,22 @@ BatchedDirectoryListing getBatchedListing(String[] srcs, byte[] startAfter,
43254325
if (dirListing == null) {
43264326
throw new FileNotFoundException("Path " + src + " does not exist");
43274327
}
4328+
if (needLocation && isObserver()) {
4329+
for (HdfsFileStatus fs : dirListing.getPartialListing()) {
4330+
if (fs instanceof HdfsLocatedFileStatus) {
4331+
LocatedBlocks lbs = ((HdfsLocatedFileStatus) fs).getLocatedBlocks();
4332+
checkBlockLocationsWhenObserver(lbs, fs.toString());
4333+
}
4334+
}
4335+
}
43284336
listing = new HdfsPartialListing(
43294337
srcsIndex, Lists.newArrayList(dirListing.getPartialListing()));
43304338
numEntries += listing.getPartialListing().size();
43314339
lastListing = dirListing;
43324340
} catch (Exception e) {
4341+
if (e instanceof ObserverRetryOnActiveException) {
4342+
throw (ObserverRetryOnActiveException) e;
4343+
}
43334344
if (e instanceof AccessControlException) {
43344345
logAuditEvent(false, operationName, src);
43354346
}
@@ -4392,6 +4403,8 @@ BatchedDirectoryListing getBatchedListing(String[] srcs, byte[] startAfter,
43924403
true,
43934404
returnedStartAfter);
43944405
}
4406+
} catch(ObserverRetryOnActiveException e){
4407+
throw e;
43954408
} finally {
43964409
readUnlock(RwLockMode.FS, operationName,
43974410
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)