Skip to content

Commit a4b76d3

Browse files
committed
HADOOP-18757. S3A Committer only finalizes the commits in a single thread (#5706)
Contributed by Moditha Hewasinghage <!-- Thanks for sending a pull request! 1. If this is your first time, please read our contributor guidelines: https://cwiki.apache.org/confluence/display/HADOOP/How+To+Contribute 2. Make sure your PR title starts with JIRA issue id, e.g., 'HADOOP-17799. Your PR title ...'. --> ### Description of PR ### How was this patch tested? ### For code changes: - [ ] Does the title or this PR starts with the corresponding JIRA issue id (e.g. 'HADOOP-17799. Your PR title ...')? - [ ] Object storage: have the integration tests been executed and the endpoint declared according to the connector-specific documentation? - [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)? - [ ] If applicable, have you updated the `LICENSE`, `LICENSE-binary`, `NOTICE-binary` files?
1 parent b6b2590 commit a4b76d3

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -2873,7 +2873,9 @@ public boolean checkBlockReportLease(BlockReportContext context,
28732873
public boolean processReport(final DatanodeID nodeID,
28742874
final DatanodeStorage storage,
28752875
final BlockListAsLongs newReport,
2876-
BlockReportContext context) throws IOException {
2876+
BlockReportContext context,
2877+
int totalReportNum,
2878+
int currentReportNum) throws IOException {
28772879
namesystem.writeLock();
28782880
final long startTime = Time.monotonicNow(); //after acquiring write lock
28792881
final long endTime;
@@ -2904,7 +2906,8 @@ public boolean processReport(final DatanodeID nodeID,
29042906
}
29052907
if (namesystem.isInStartupSafeMode()
29062908
&& !StorageType.PROVIDED.equals(storageInfo.getStorageType())
2907-
&& storageInfo.getBlockReportCount() > 0) {
2909+
&& storageInfo.getBlockReportCount() > 0
2910+
&& totalReportNum == currentReportNum) {
29082911
blockLog.info("BLOCK* processReport 0x{} with lease ID 0x{}: "
29092912
+ "discarded non-initial block report from {}"
29102913
+ " because namenode still in startup phase",

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1650,7 +1650,7 @@ public DatanodeCommand blockReport(final DatanodeRegistration nodeReg,
16501650
final int index = r;
16511651
noStaleStorages = bm.runBlockOp(() ->
16521652
bm.processReport(nodeReg, reports[index].getStorage(),
1653-
blocks, context));
1653+
blocks, context, reports.length, index+1));
16541654
}
16551655
} else {
16561656
throw new InvalidBlockReportLeaseException(context.getReportId(), context.getLeaseId());

hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestBlockManager.java

+9-9
Original file line numberDiff line numberDiff line change
@@ -1080,12 +1080,12 @@ public void testSafeModeIBR() throws Exception {
10801080
reset(node);
10811081

10821082
bm.processReport(node, new DatanodeStorage(ds.getStorageID()),
1083-
BlockListAsLongs.EMPTY, null);
1083+
BlockListAsLongs.EMPTY, null, 1, 1);
10841084
assertEquals(1, ds.getBlockReportCount());
10851085
// send block report again, should NOT be processed
10861086
reset(node);
10871087
bm.processReport(node, new DatanodeStorage(ds.getStorageID()),
1088-
BlockListAsLongs.EMPTY, null);
1088+
BlockListAsLongs.EMPTY, null, 1, 1);
10891089
assertEquals(1, ds.getBlockReportCount());
10901090

10911091
// re-register as if node restarted, should update existing node
@@ -1096,7 +1096,7 @@ public void testSafeModeIBR() throws Exception {
10961096
// send block report, should be processed after restart
10971097
reset(node);
10981098
bm.processReport(node, new DatanodeStorage(ds.getStorageID()),
1099-
BlockListAsLongs.EMPTY, null);
1099+
BlockListAsLongs.EMPTY, null, 1, 1);
11001100
// Reinitialize as registration with empty storage list pruned
11011101
// node.storageMap.
11021102
ds = node.getStorageInfos()[0];
@@ -1125,7 +1125,7 @@ public void testSafeModeIBRAfterIncremental() throws Exception {
11251125
reset(node);
11261126
doReturn(1).when(node).numBlocks();
11271127
bm.processReport(node, new DatanodeStorage(ds.getStorageID()),
1128-
BlockListAsLongs.EMPTY, null);
1128+
BlockListAsLongs.EMPTY, null, 1, 1);
11291129
assertEquals(1, ds.getBlockReportCount());
11301130
}
11311131

@@ -1198,7 +1198,7 @@ public void testSafeModeIBRBeforeFirstFullBR() throws Exception {
11981198
// Make sure it's the first full report
11991199
assertEquals(0, ds.getBlockReportCount());
12001200
bm.processReport(node, new DatanodeStorage(ds.getStorageID()),
1201-
builder.build(), null);
1201+
builder.build(), null, 1, 1);
12021202
assertEquals(1, ds.getBlockReportCount());
12031203

12041204
// verify the storage info is correct
@@ -1249,12 +1249,12 @@ public void testSafeModeWithProvidedStorageBR() throws Exception {
12491249
bmPs.getDatanodeManager().addDatanode(node1);
12501250

12511251
// process reports of provided storage and disk storage
1252-
bmPs.processReport(node0, providedStorage, BlockListAsLongs.EMPTY, null);
1252+
bmPs.processReport(node0, providedStorage, BlockListAsLongs.EMPTY, null, 2, 1);
12531253
bmPs.processReport(node0, new DatanodeStorage(ds0.getStorageID()),
1254-
BlockListAsLongs.EMPTY, null);
1255-
bmPs.processReport(node1, providedStorage, BlockListAsLongs.EMPTY, null);
1254+
BlockListAsLongs.EMPTY, null, 2, 2);
1255+
bmPs.processReport(node1, providedStorage, BlockListAsLongs.EMPTY, null, 2, 1);
12561256
bmPs.processReport(node1, new DatanodeStorage(ds1.getStorageID()),
1257-
BlockListAsLongs.EMPTY, null);
1257+
BlockListAsLongs.EMPTY, null, 2, 2);
12581258

12591259
// The provided stoage report should not affect disk storage report
12601260
DatanodeStorageInfo dsPs =

0 commit comments

Comments
 (0)