Skip to content

Conversation

@ZanderXu
Copy link
Contributor

Description of PR

The blockReport RPC should throw UnregisteredNodeException when the storedDN is null, the related code as bellows:

public void removeBRLeaseIfNeeded(final DatanodeID nodeID,
      final BlockReportContext context) throws IOException {
    namesystem.writeLock();
    DatanodeDescriptor node;
    try {
      // Here, if the node is null, we should throw UnregisteredNodeException insteat of NPE
      node = datanodeManager.getDatanode(nodeID);
      if (context != null) {
        if (context.getTotalRpcs() == context.getCurRpc() + 1) {
          long leaseId = this.getBlockReportLeaseManager().removeLease(node);
          BlockManagerFaultInjector.getInstance().
              removeBlockReportLease(node, leaseId);
          node.setLastBlockReportTime(now());
          node.setLastBlockReportMonotonic(Time.monotonicNow());
        }
        if (LOG.isDebugEnabled()) {
          LOG.debug("Processing RPC with index {} out of total {} RPCs in processReport 0x{}",
              context.getCurRpc(), context.getTotalRpcs(), Long.toHexString(context.getReportId()));
        }
      }
    } finally {
      namesystem.writeUnlock("removeBRLeaseIfNeeded");
    }
  }

@zhangshuyan0
Copy link
Contributor

zhangshuyan0 commented Mar 22, 2023

I found that when BlockManager#removeBRLeaseIfNeeded is called, BlockManager#checkBlockReportLease must have been called in advance. BlockManager#checkBlockReportLease already checked whether the nodeID exists in datanodeManager, is it necessary for us to check it again in BlockManager#removeBRLeaseIfNeeded?

public boolean checkBlockReportLease(BlockReportContext context,
final DatanodeID nodeID) throws UnregisteredNodeException {
if (context == null) {
return true;
}
DatanodeDescriptor node = datanodeManager.getDatanode(nodeID);
if (node == null) {
throw new UnregisteredNodeException(nodeID, null);
}

@ZanderXu
Copy link
Contributor Author

I found that when BlockManager#removeBRLeaseIfNeeded is called, BlockManager#checkBlockReportLease must have been called in advance. BlockManager#checkBlockReportLease already checked whether the nodeID exists in datanodeManager, is it necessary for us to check it again in BlockManager#removeBRLeaseIfNeeded?

public boolean checkBlockReportLease(BlockReportContext context,
final DatanodeID nodeID) throws UnregisteredNodeException {
if (context == null) {
return true;
}
DatanodeDescriptor node = datanodeManager.getDatanode(nodeID);
if (node == null) {
throw new UnregisteredNodeException(nodeID, null);
}

@zhangshuyan0 Thanks for your review. I think we should check it again in BlockManager#removeBRLeaseIfNeeded, because there is a segment lock that bm.processReport() will unlock the write and BlockManager#removeBRLeaseIfNeeded hold the lock again. And there is a case that the datanode is removed after bm.processReport() and before BlockManager#removeBRLeaseIfNeeded.

@zhangshuyan0
Copy link
Contributor

@ZanderXu Thanks for reply. It sounds like it makes sense. DatanodeDescriptor only can be removed from datanodeMap when registerDatanode() is called. I'm not sure if this is even possible to happen between checkBlockReportLease() and removeBRLeaseIfNeeded (). May need a UT to reproduce related problems.

@hadoop-yetus
Copy link

💔 -1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 0m 56s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 0s No case conflicting files found.
+0 🆗 codespell 0m 1s codespell was not available.
+0 🆗 detsecrets 0m 1s detect-secrets was not available.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
-1 ❌ test4tests 0m 0s The patch doesn't appear to include any new or modified tests. Please justify why no new tests are needed for this patch. Also please list what manual steps were performed to verify this patch.
_ trunk Compile Tests _
+1 💚 mvninstall 41m 54s trunk passed
+1 💚 compile 1m 28s trunk passed with JDK Ubuntu-11.0.18+10-post-Ubuntu-0ubuntu120.04.1
+1 💚 compile 1m 19s trunk passed with JDK Private Build-1.8.0_362-8u362-ga-0ubuntu1~20.04.1-b09
+1 💚 checkstyle 1m 6s trunk passed
+1 💚 mvnsite 1m 30s trunk passed
+1 💚 javadoc 1m 7s trunk passed with JDK Ubuntu-11.0.18+10-post-Ubuntu-0ubuntu120.04.1
+1 💚 javadoc 1m 33s trunk passed with JDK Private Build-1.8.0_362-8u362-ga-0ubuntu1~20.04.1-b09
+1 💚 spotbugs 3m 33s trunk passed
+1 💚 shadedclient 25m 51s branch has no errors when building and testing our client artifacts.
_ Patch Compile Tests _
+1 💚 mvninstall 1m 19s the patch passed
+1 💚 compile 1m 24s the patch passed with JDK Ubuntu-11.0.18+10-post-Ubuntu-0ubuntu120.04.1
+1 💚 javac 1m 24s the patch passed
+1 💚 compile 1m 14s the patch passed with JDK Private Build-1.8.0_362-8u362-ga-0ubuntu1~20.04.1-b09
+1 💚 javac 1m 14s the patch passed
+1 💚 blanks 0m 0s The patch has no blanks issues.
+1 💚 checkstyle 0m 55s the patch passed
+1 💚 mvnsite 1m 20s the patch passed
+1 💚 javadoc 0m 53s the patch passed with JDK Ubuntu-11.0.18+10-post-Ubuntu-0ubuntu120.04.1
+1 💚 javadoc 1m 27s the patch passed with JDK Private Build-1.8.0_362-8u362-ga-0ubuntu1~20.04.1-b09
+1 💚 spotbugs 3m 27s the patch passed
+1 💚 shadedclient 25m 30s patch has no errors when building and testing our client artifacts.
_ Other Tests _
-1 ❌ unit 248m 55s /patch-unit-hadoop-hdfs-project_hadoop-hdfs.txt hadoop-hdfs in the patch passed.
+1 💚 asflicense 0m 43s The patch does not generate ASF License warnings.
365m 7s
Reason Tests
Failed junit tests hadoop.hdfs.server.sps.TestExternalStoragePolicySatisfier
hadoop.hdfs.server.datanode.TestDirectoryScanner
Subsystem Report/Notes
Docker ClientAPI=1.42 ServerAPI=1.42 base: https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-5500/1/artifact/out/Dockerfile
GITHUB PR #5500
Optional Tests dupname asflicense compile javac javadoc mvninstall mvnsite unit shadedclient spotbugs checkstyle codespell detsecrets
uname Linux 3cc2e9060108 4.15.0-206-generic #217-Ubuntu SMP Fri Feb 3 19:10:13 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/bin/hadoop.sh
git revision trunk / bb90232
Default Java Private Build-1.8.0_362-8u362-ga-0ubuntu1~20.04.1-b09
Multi-JDK versions /usr/lib/jvm/java-11-openjdk-amd64:Ubuntu-11.0.18+10-post-Ubuntu-0ubuntu120.04.1 /usr/lib/jvm/java-8-openjdk-amd64:Private Build-1.8.0_362-8u362-ga-0ubuntu1~20.04.1-b09
Test Results https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-5500/1/testReport/
Max. process+thread count 2430 (vs. ulimit of 5500)
modules C: hadoop-hdfs-project/hadoop-hdfs U: hadoop-hdfs-project/hadoop-hdfs
Console output https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-5500/1/console
versions git=2.25.1 maven=3.6.3 spotbugs=4.2.2
Powered by Apache Yetus 0.14.0 https://yetus.apache.org

This message was automatically generated.

@Hexiaoqiao
Copy link
Contributor

@ZanderXu Thanks for your works.

I'm not sure if this is even possible to happen between checkBlockReportLease() and removeBRLeaseIfNeeded().

+1, I am not sure if it is possible to happen after dig this code segment. Did you ever meet some NPE here?

@github-actions
Copy link
Contributor

We're closing this stale PR because it has been open for 100 days with no activity. This isn't a judgement on the merit of the PR in any way. It's just a way of keeping the PR queue manageable.
If you feel like this was a mistake, or you would like to continue working on it, please feel free to re-open it and ask for a committer to remove the stale tag and review again.
Thanks all for your contribution.

@github-actions github-actions bot added the Stale label Oct 23, 2025
@github-actions github-actions bot closed this Oct 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants