{"record":{"id":"e8ed9027f2e49dfc","repo":"apache/hadoop","slug":"block-not-found","errorCode":null,"errorMessage":"Block (={}) not found","messagePattern":"Block \\(=(.+?)\\) not found","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java","lineNumber":4088,"sourceCode":"    boolean copyTruncate = false;\n    BlockInfo truncatedBlock = null;\n    try {\n      checkOperation(OperationCategory.WRITE);\n      // If a DN tries to commit to the standby, the recovery will\n      // fail, and the next retry will succeed on the new NN.\n  \n      checkNameNodeSafeMode(\n          \"Cannot commitBlockSynchronization while in safe mode\");\n      final BlockInfo storedBlock = getStoredBlock(\n          ExtendedBlock.getLocalBlock(oldBlock));\n      if (storedBlock == null) {\n        if (deleteblock) {\n          // This may be a retry attempt so ignore the failure\n          // to locate the block.\n          LOG.debug(\"Block (={}) not found\", oldBlock);\n          return;\n        } else {\n          throw new IOException(\"Block (=\" + oldBlock + \") not found\");\n        }\n      }\n      final long oldGenerationStamp = storedBlock.getGenerationStamp();\n      final long oldNumBytes = storedBlock.getNumBytes();\n      //\n      // The implementation of delete operation (see @deleteInternal method)\n      // first removes the file paths from namespace, and delays the removal\n      // of blocks to later time for better performance. When\n      // commitBlockSynchronization (this method) is called in between, the\n      // blockCollection of storedBlock could have been assigned to null by\n      // the delete operation, throw IOException here instead of NPE; if the\n      // file path is already removed from namespace by the delete operation,\n      // throw FileNotFoundException here, so not to proceed to the end of\n      // this method to add a CloseOp to the edit log for an already deleted\n      // file (See HDFS-6825).\n      //\n      if (storedBlock.isDeleted()) {\n        throw new IOException(\"The blockCollection of \" + storedBlock","sourceCodeStart":4070,"sourceCodeEnd":4106,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java#L4070-L4106","documentation":"commitBlockSynchronization could not find storedBlock for the old block in the NameNode blocks map. With deleteblock=true this is treated as a benign retry (debug log, no-op return); with deleteblock=false it throws IOException because there is no block state left to synchronize.","triggerScenarios":"Client retries commitBlockSynchronization after the block was already removed: the owning file was deleted, a previous recovery invalidated the block, or the ExtendedBlock carries the wrong block pool id.","commonSituations":"File deleted while pipeline recovery was in flight; retry of a failed pipeline setup after another client's lease recovery already reorganized the last block; multi-cluster configs mixing block pool ids.","solutions":["Check whether the file still exists; if it was deleted, swallow the error (nothing to commit)","Otherwise re-fetch current block info via getBlockLocations/LocatedBlock and redo the update with fresh block identity and GS","Verify the block pool id in the ExtendedBlock matches the namenode being called"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if (!fs.exists(new Path(src))) {\n  return; // file gone: nothing to commit\n}\nLocatedBlocks lbs = dfs.getClient().getLocatedBlocks(path, 0);\n// verify oldBlock id still present in lbs before syncing","typeGuard":null,"tryCatchPattern":"try {\n  commitBlockSynchronization(oldBlock, newGs, newLen, ...);\n} catch (IOException e) {\n  if (e.getMessage().contains(\"Block (\") && e.getMessage().contains(\") not found\")\n      && !fs.exists(path)) {\n    return; // benign: file deleted, block removed\n  }\n  throw e;\n}","preventionTips":["Confirm file existence before retrying block synchronization","Use fresh LocatedBlock data for retries instead of cached block ids","Match block pool ids when operating across clusters"],"tags":["hdfs","namenode","block-not-found","pipeline-recovery","retry"],"backgroundTag":"block-not-found","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}