zhangshuyan0 commented on code in PR #5855:
URL: https://github.com/apache/hadoop/pull/5855#discussion_r1278756125


##########
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestBlockReportLease.java:
##########
@@ -269,4 +272,84 @@ private StorageBlockReport[] 
createReports(DatanodeStorage[] dnStorages,
     }
     return storageBlockReports;
   }
+
+  @Test

Review Comment:
   Need add a timeout here.



##########
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java:
##########
@@ -2904,7 +2908,8 @@ public boolean processReport(final DatanodeID nodeID,
       }
       if (namesystem.isInStartupSafeMode()
           && !StorageType.PROVIDED.equals(storageInfo.getStorageType())
-          && storageInfo.getBlockReportCount() > 0) {
+          && storageInfo.getBlockReportCount() > 0
+          && totalReportNum == currentReportNum) {

Review Comment:
   If a datanode report twice during namenode safemode, the second report will 
be almost completely processed, which may extend startup time. How about modify 
code like this? This can also avoid changes in the method signature.
   ```
   if (namesystem.isInStartupSafeMode()
             && !StorageType.PROVIDED.equals(storageInfo.getStorageType())
             && storageInfo.getBlockReportCount() > 0) {
           blockLog.info("BLOCK* processReport 0x{} with lease ID 0x{}: "
               + "discarded non-initial block report from datanode {} storage 
{} "
               + " because namenode still in startup phase",
               strBlockReportId, fullBrLeaseId, nodeID, 
storageInfo.getStorageID());
           boolean needRemoveLease = true;
           for (DatanodeStorageInfo sInfo : node.getStorageInfos()) {
             if (sInfo.getBlockReportCount() == 0) {
               needRemoveLease = false;
             }
           }
           if (needRemoveLease) {
             blockReportLeaseManager.removeLease(node);
           }
           return !node.hasStaleStorages();
         }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to