apache/hadoop · critical · FileNotFoundException

No valid image files found

Error message

No valid image files found

What it means

The transactional storage inspector (Hadoop 2.x+ checkpoint layout, fsimage_<txid>) scans all dfs.namenode.name.dir directories for image files. If not one fsimage is found, getLatestImages() throws FileNotFoundException('No valid image files found') and the NameNode cannot boot — almost always unformatted or misconfigured name directories rather than corruption.

Source

Thrown at hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImageTransactionalStorageInspector.java:159

   */
  @Override
  List<FSImageFile> getLatestImages() throws IOException {
    LinkedList<FSImageFile> ret = new LinkedList<FSImageFile>();
    for (FSImageFile img : foundImages) {
      if (ret.isEmpty()) {
        ret.add(img);
      } else {
        FSImageFile cur = ret.getFirst();
        if (cur.txId == img.txId) {
          ret.add(img);
        } else if (cur.txId < img.txId) {
          ret.clear();
          ret.add(img);
        }
      }
    }
    if (ret.isEmpty()) {
      throw new FileNotFoundException("No valid image files found");
    }
    return ret;
  }
  
  public List<FSImageFile> getFoundImages() {
    return ImmutableList.copyOf(foundImages);
  }
  
  @Override
  public boolean needToSave() {
    return needToSave;
  }

  @Override
  long getMaxSeenTxId() {
    return maxSeenTxId;
  }
}

View on GitHub (pinned to 2add963021)

Solutions

  1. Confirm what is on disk: ls <name.dir>/current for every configured directory
  2. Fix dfs.namenode.name.dir to the real storage paths and restart
  3. For a brand-new/dev cluster run 'hdfs namenode -format' (destroys the namespace — dev only)
  4. For an existing cluster restore fsimage_<txid> + fsimage.md5 + seen_txid from backup, or import a checkpoint

Example fix

# before: empty storage dir
ls /dfs/name/current/   # nothing (or no current/ at all)
# after: either restore a checkpoint ...
cp /backup/fsimage_0000000000000085000* /backup/seen_txid /dfs/name/current/
# ... or, for a throwaway dev cluster
hdfs namenode -format
Defensive patterns

Strategy: validation

Validate before calling

for (URI u : FSNamesystem.getNamespaceDirs(conf)) {
  File cur = new File(u.getPath(), Storage.STORAGE_DIR_CURRENT);
  File[] imgs = cur.listFiles((d, n) -> n.startsWith("fsimage_"));
  if (imgs == null || imgs.length == 0) {
    LOG.error("no fsimage_<txid> in " + cur + " - NameNode will fail to start");
  }
}

Try / catch

catch FileNotFoundException from FSImage loading — distinguish 'no valid image files found' (unformatted/wrong dirs; fix config or format) from per-file IO errors before retrying.

Prevention

When it happens

Trigger: getLatestImages() after inspectStorage() located zero fsimage_<txid> files: fresh install never formatted, dfs.namenode.name.dir pointing at empty or wrong paths, images deleted, or a mount not attached.

Common situations: First startup without 'hdfs namenode -format'; typo'd or stale name.dir after host migration; disk unmounted; images removed by cleanup scripts.

Related errors


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