{"record":{"id":"e17d6c4eef8e5c5b","repo":"apache/hadoop","slug":"meta-file-not-found-blockfile-blockfile","errorCode":null,"errorMessage":"Meta file not found, blockFile={blockFile}","messagePattern":"Meta file not found, blockFile=(.+?)","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"critical","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetUtil.java","lineNumber":102,"sourceCode":"  static File getMetaFile(File f, long gs) {\n    return new File(f.getParent(),\n        DatanodeUtil.getMetaName(f.getName(), gs));\n  }\n\n  /** Find the corresponding meta data file from a given block file */\n  public static File findMetaFile(final File blockFile) throws IOException {\n    final String prefix = blockFile.getName() + \"_\";\n    final File parent = blockFile.getParentFile();\n    final File[] matches = parent.listFiles(new FilenameFilter() {\n      @Override\n      public boolean accept(File dir, String name) {\n        return dir.equals(parent) && name.startsWith(prefix)\n            && name.endsWith(Block.METADATA_EXTENSION);\n      }\n    });\n\n    if (matches == null || matches.length == 0) {\n      throw new FileNotFoundException(\n          \"Meta file not found, blockFile=\" + blockFile);\n    }\n    if (matches.length > 1) {\n      throw new IOException(\"Found more than one meta files: \" \n          + Arrays.asList(matches));\n    }\n    return matches[0];\n  }\n\n  public static FileDescriptor openAndSeek(File file, long offset)\n      throws IOException {\n    RandomAccessFile raf = null;\n    try {\n      raf = new RandomAccessFile(file, \"r\");\n      if (offset > 0) {\n        raf.seek(offset);\n      }\n      return raf.getFD();","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetUtil.java#L84-L120","documentation":"FsDatasetUtil.findMetaFile expects exactly one '<blockFile>_<generationStamp>.meta' beside a block file. FileNotFoundException means zero matches: the replica has no checksum metadata. A finalized block without its .meta file cannot be served or verified, so this signals a lost or half-created file.","triggerScenarios":"DN crash between block-file creation and meta-file creation; .meta lost on a failing volume; backup/antivirus/graceful-copy tooling stripping .meta files; recovery scanning a volume mid-delete.","commonSituations":"Post-crash restarts; failing disks; external tools touching finalized dirs; DirectoryScanner reconciling orphan files.","solutions":["Let the DirectoryScanner repair it: it deletes the orphan block file and updates the NN (keep dfs.datanode.directoryscan.interval non-zero; default 21600s), then re-replication restores the block.","For an immediate fix, delete the orphan block file (block without meta) manually and run 'hdfs fsck' to trigger re-replication.","Investigate why the meta vanished: disk health, external tooling touching replica dirs.","If it recurs for the same block on every restart, remove that block subdirectory and let re-replication heal."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"File[] metas = blockFile.getParentFile().listFiles(\n    (d, n) -> n.startsWith(blockFile.getName() + \"_\") && n.endsWith(\".meta\"));\nif (metas == null || metas.length == 0) {\n  // no meta: quarantine or delete the orphan block file\n}","typeGuard":null,"tryCatchPattern":"try {\n  File meta = FsDatasetUtil.findMetaFile(blockFile);\n} catch (FileNotFoundException e) {\n  // orphan block file: remove it and let the NN re-replicate\n}","preventionTips":["Keep dfs.datanode.directoryscan.interval non-zero so DirectoryScanner reconciles orphans.","Exclude replica directories from backup/antivirus tools that strip .meta files.","Monitor volumes for corruption; missing metas often precede disk failure."],"tags":["hdfs","datanode","metadata","checksum","orphan-block"],"backgroundTag":"hdfs-missing-block-metadata","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}