{"record":{"id":"279354112b2b4440","repo":"apache/hadoop","slug":"could-not-obtain-block","errorCode":null,"errorMessage":"Could not obtain block {}","messagePattern":"Could not obtain block (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NamenodeFsck.java","lineNumber":1082,"sourceCode":"   * around.\n   */\n  private void copyBlock(final DFSClient dfs, LocatedBlock lblock,\n      OutputStream fos) throws Exception {\n    int failures = 0;\n    InetSocketAddress targetAddr = null;\n    Set<DatanodeInfo> deadNodes = new HashSet<DatanodeInfo>();\n    BlockReader blockReader = null;\n    ExtendedBlock block = lblock.getBlock();\n\n    while (blockReader == null) {\n      DatanodeInfo chosenNode;\n\n      try {\n        chosenNode = bestNode(dfs, lblock.getLocations(), deadNodes);\n        targetAddr = NetUtils.createSocketAddr(chosenNode.getXferAddr());\n      }  catch (IOException ie) {\n        if (failures >= HdfsClientConfigKeys.DFS_CLIENT_MAX_BLOCK_ACQUIRE_FAILURES_DEFAULT) {\n          throw new IOException(\"Could not obtain block \" + lblock, ie);\n        }\n        LOG.info(\"Could not obtain block from any node:  \" + ie);\n        try {\n          Thread.sleep(10000);\n        }  catch (InterruptedException iex) {\n        }\n        deadNodes.clear();\n        failures++;\n        continue;\n      }\n      try {\n        String file = BlockReaderFactory.getFileName(targetAddr,\n            block.getBlockPoolId(), block.getBlockId());\n        blockReader = new BlockReaderFactory(dfs.getConf()).\n            setFileName(file).\n            setBlock(block).\n            setBlockToken(lblock.getBlockToken()).\n            setStartOffset(0).","sourceCodeStart":1064,"sourceCodeEnd":1100,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NamenodeFsck.java#L1064-L1100","documentation":"Error \"Could not obtain block {}\" thrown in apache/hadoop.","triggerScenarios":"fsck fails to fetch a block's contents from any DataNode holding a replica.","commonSituations":"Corrupted or unreachable DataNodes while fsck verifies block data.","solutions":["Retry the fsck; if persistent, check DataNode availability and network connectivity for the block's replicas."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}