Skip to content

Commit 448bbe1

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

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
@@ -4188,11 +4188,22 @@ BatchedDirectoryListing getBatchedListing(String[] srcs, byte[] startAfter,
41884188
if (dirListing == null) {
41894189
throw new FileNotFoundException("Path " + src + " does not exist");
41904190
}
4191+
if (needLocation && isObserver()) {
4192+
for (HdfsFileStatus fs : dirListing.getPartialListing()) {
4193+
if (fs instanceof HdfsLocatedFileStatus) {
4194+
LocatedBlocks lbs = ((HdfsLocatedFileStatus) fs).getLocatedBlocks();
4195+
checkBlockLocationsWhenObserver(lbs, fs.toString());
4196+
}
4197+
}
4198+
}
41914199
listing = new HdfsPartialListing(
41924200
srcsIndex, Lists.newArrayList(dirListing.getPartialListing()));
41934201
numEntries += listing.getPartialListing().size();
41944202
lastListing = dirListing;
41954203
} catch (Exception e) {
4204+
if (e instanceof ObserverRetryOnActiveException) {
4205+
throw (ObserverRetryOnActiveException) e;
4206+
}
41964207
if (e instanceof AccessControlException) {
41974208
logAuditEvent(false, operationName, src);
41984209
}
@@ -4255,6 +4266,8 @@ BatchedDirectoryListing getBatchedListing(String[] srcs, byte[] startAfter,
42554266
true,
42564267
returnedStartAfter);
42574268
}
4269+
} catch(ObserverRetryOnActiveException e){
4270+
throw e;
42584271
} finally {
42594272
readUnlock(operationName);
42604273
}

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
@@ -376,6 +376,9 @@ public void testObserverNodeBlockMissingRetry() throws Exception {
376376
dfs.getClient().getLocatedFileInfo(testPath.toString(), false);
377377
assertSentTo(0);
378378

379+
dfs.getClient().batchedListPaths(new String[]{"/"}, new byte[0], true);
380+
assertSentTo(0);
381+
379382
Mockito.reset(bmSpy);
380383
}
381384

0 commit comments

Comments
 (0)