{"record":{"id":"6f54604e452b3a66","repo":"apache/hadoop","slug":"failed-to-report-bad-block-to-namenode","errorCode":null,"errorMessage":"Failed to report bad block {} to namenode.","messagePattern":"Failed to report bad block (.+?) to namenode\\.","errorType":"exception","errorClass":"BPServiceActorActionException","httpStatus":null,"severity":"warning","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/ReportBadBlockAction.java","lineNumber":70,"sourceCode":"  public void reportTo(DatanodeProtocolClientSideTranslatorPB bpNamenode, \n    DatanodeRegistration bpRegistration) throws BPServiceActorActionException {\n    if (bpRegistration == null) {\n      return;\n    }\n    DatanodeInfo[] dnArr = {new DatanodeInfoBuilder()\n        .setNodeID(bpRegistration).build()};\n    String[] uuids = { storageUuid };\n    StorageType[] types = { storageType };\n    LocatedBlock[] locatedBlock = { new LocatedBlock(block,\n        dnArr, uuids, types) };\n\n    try {\n      bpNamenode.reportBadBlocks(locatedBlock);\n    } catch (RemoteException re) {\n      DataNode.LOG.info(\"reportBadBlock encountered RemoteException for \"\n          + \"block:  \" + block , re);\n    } catch (IOException e) {\n      throw new BPServiceActorActionException(\"Failed to report bad block \"\n          + block + \" to namenode.\", e);\n    }\n  }\n\n  @Override\n  public int hashCode() {\n    final int prime = 31;\n    int result = 1;\n    result = prime * result + ((block == null) ? 0 : block.hashCode());\n    result = prime * result\n        + ((storageType == null) ? 0 : storageType.hashCode());\n    result = prime * result\n        + ((storageUuid == null) ? 0 : storageUuid.hashCode());\n    return result;\n  }\n\n  @Override\n  public boolean equals(Object obj) {","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/ReportBadBlockAction.java#L52-L88","documentation":"ReportBadBlockAction.execute() calls bpNamenode.reportBadBlocks(locatedBlock) to tell the NameNode a block replica is corrupt. A RemoteException (an error raised BY the NameNode, e.g. 'replica is not corrupt' or 'block does not exist') is only logged at info level, but any other IOException (transport failure, timeout, NN unreachable) is wrapped in BPServiceActorActionException so the BPOfferService action queue can retry it later.","triggerScenarios":"The DataNode's DataNodeFaultInjector or a checksum failure queues a ReportBadBlockAction; when the queued action runs, the RPC to the NameNode fails with a non-RemoteException IOException - NameNode down/restarting, network partition, RPC queue full/timeout, HA failover in progress.","commonSituations":"Transient NameNode unavailability during HA failover while the DN reports corrupt blocks; network issues between DN and NN; the same bad block reported repeatedly because earlier reports never landed.","solutions":["Verify NameNode reachability and health (its UI/RPC port) - the action is already retried by the BPServiceActor thread, so a transient NN outage self-heals","Check for active-standby flip-flop or split-brain causing repeated RPC failures","If it persists, capture the cause in BPServiceActorActionException and inspect the underlying IOException (timeout vs connection refused) to target the real network/config issue"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"import org.apache.hadoop.ha.HAServiceProtocol;\n// before executing bad-block reports, confirm the NN is up and active\nboolean nnReady = dfsCluster != null && haServiceState == HAServiceProtocol.HAServiceState.ACTIVE;","typeGuard":null,"tryCatchPattern":"catch (BPServiceActorActionException e) {\n  // action stays queued and retried by BPOfferService; log at info, do not crash the actor thread\n  LOG.info(\"Bad block report deferred, will retry: {}\", e.getMessage());\n}","preventionTips":["Keep NameNode HA failover healthy - transient reportBadBlocks failures are retried automatically","Monitor DN logs for repeated 'Failed to report bad block' - persistence indicates NN/RPC trouble, not disk trouble"],"tags":["hdfs","datanode","namenode","rpc","bad-block","retry-queue"],"backgroundTag":"rpc-call-failed","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}