apache/hadoop · critical · FileNotFoundException

Meta file not found, blockFile={blockFile}

Error message

Meta file not found, blockFile={blockFile}

What it means

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.

Source

Thrown at hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetUtil.java:102

  static File getMetaFile(File f, long gs) {
    return new File(f.getParent(),
        DatanodeUtil.getMetaName(f.getName(), gs));
  }

  /** Find the corresponding meta data file from a given block file */
  public static File findMetaFile(final File blockFile) throws IOException {
    final String prefix = blockFile.getName() + "_";
    final File parent = blockFile.getParentFile();
    final File[] matches = parent.listFiles(new FilenameFilter() {
      @Override
      public boolean accept(File dir, String name) {
        return dir.equals(parent) && name.startsWith(prefix)
            && name.endsWith(Block.METADATA_EXTENSION);
      }
    });

    if (matches == null || matches.length == 0) {
      throw new FileNotFoundException(
          "Meta file not found, blockFile=" + blockFile);
    }
    if (matches.length > 1) {
      throw new IOException("Found more than one meta files: " 
          + Arrays.asList(matches));
    }
    return matches[0];
  }

  public static FileDescriptor openAndSeek(File file, long offset)
      throws IOException {
    RandomAccessFile raf = null;
    try {
      raf = new RandomAccessFile(file, "r");
      if (offset > 0) {
        raf.seek(offset);
      }
      return raf.getFD();

View on GitHub (pinned to 2add963021)

Solutions

  1. 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.
  2. For an immediate fix, delete the orphan block file (block without meta) manually and run 'hdfs fsck' to trigger re-replication.
  3. Investigate why the meta vanished: disk health, external tooling touching replica dirs.
  4. If it recurs for the same block on every restart, remove that block subdirectory and let re-replication heal.
Defensive patterns

Strategy: try-catch

Validate before calling

File[] metas = blockFile.getParentFile().listFiles(
    (d, n) -> n.startsWith(blockFile.getName() + "_") && n.endsWith(".meta"));
if (metas == null || metas.length == 0) {
  // no meta: quarantine or delete the orphan block file
}

Try / catch

try {
  File meta = FsDatasetUtil.findMetaFile(blockFile);
} catch (FileNotFoundException e) {
  // orphan block file: remove it and let the NN re-replicate
}

Prevention

When it happens

Trigger: 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.

Common situations: Post-crash restarts; failing disks; external tools touching finalized dirs; DirectoryScanner reconciling orphan files.

Related errors


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/e17d6c4eef8e5c5b. Report an issue: GitHub.