apache/hadoop · error · IOException

Unable to create aliasmap snapshot directory {newLevelDBDir}

Error message

Unable to create aliasmap snapshot directory {newLevelDBDir}

What it means

InMemoryAliasMap.createSnapshot throws IOException when mkdirs() on the target snapshot LevelDB directory fails. The snapshot path is <aliasmap-parent>/aliasmap_snapshot/<bpid>; if that dir cannot be created — usually because it already exists from a previous failed snapshot run, or because of missing permissions — the copy of the LevelDB store cannot proceed.

Source

Thrown at hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/aliasmap/InMemoryAliasMap.java:290

    }
  }

  /**
   * Create a new LevelDB store which is a snapshot copy of the original
   * aliasmap.
   *
   * @param aliasMap original aliasmap.
   * @return the {@link File} where the snapshot is created.
   * @throws IOException
   */
  static File createSnapshot(InMemoryAliasMap aliasMap) throws IOException {
    File originalAliasMapDir = new File(aliasMap.aliasMapURI);
    String bpid = originalAliasMapDir.getName();
    File snapshotDir =
        new File(originalAliasMapDir.getParent(), SNAPSHOT_COPY_DIR);
    File newLevelDBDir = new File(snapshotDir, bpid);
    if (!newLevelDBDir.mkdirs()) {
      throw new IOException(
          "Unable to create aliasmap snapshot directory " + newLevelDBDir);
    }
    // get a snapshot for the original DB.
    DB originalDB = aliasMap.levelDb;
    try (Snapshot snapshot = originalDB.getSnapshot()) {
      // create a new DB for the snapshot and copy all K,V pairs.
      Options options = new Options();
      options.createIfMissing(true);
      try (DB snapshotDB = JniDBFactory.factory.open(newLevelDBDir, options)) {
        try (DBIterator iterator =
            originalDB.iterator(new ReadOptions().snapshot(snapshot))) {
          iterator.seekToFirst();
          while (iterator.hasNext()) {
            Map.Entry<byte[], byte[]> entry = iterator.next();
            snapshotDB.put(entry.getKey(), entry.getValue());
          }
        }
      }

View on GitHub (pinned to 2add963021)

Solutions

  1. Remove the stale snapshot tree first: rm -rf <parent>/aliasmap_snapshot/<bpid> (or the whole aliasmap_snapshot dir) and retry the snapshot/bootstrap.
  2. Ensure only one process performs aliasmap snapshotting at a time (serialize NN-side bootstrap operations).
  3. Check write permissions on <parent> for the service user.
  4. If it recurs, look for the earlier failure in logs that abandoned the snapshot and fix that root cause first.

Example fix

# before
# IOException: Unable to create aliasmap snapshot directory /data/aliasmap_snapshot/BP-1234
ls /data/aliasmap_snapshot/BP-1234   # leftover from previous aborted run

# after
rm -rf /data/aliasmap_snapshot
# rerun the aliasmap snapshot / bootstrap-transfer
Defensive patterns

Strategy: validation

Validate before calling

File snapDir = new File(originalDir.getParent(), "aliasmap_snapshot");
File target = new File(snapDir, bpid);
if (target.exists()) {
  FileUtil.fullyDelete(target); // clear stale snapshot from a prior aborted run
}
File snap = InMemoryAliasMap.createSnapshot(aliasMap);

Try / catch

try {
  snapshot = InMemoryAliasMap.createSnapshot(aliasMap);
} catch (IOException e) {
  if (e.getMessage() != null && e.getMessage().startsWith("Unable to create aliasmap snapshot")) {
    FileUtil.fullyDelete(new File(parent, "aliasmap_snapshot"));
    snapshot = InMemoryAliasMap.createSnapshot(aliasMap); // one retry after cleanup
  } else { throw e; }
}

Prevention

When it happens

Trigger: createSnapshot(aliasMap) computes newLevelDBDir = <parent>/aliasmap_snapshot/<bpid> and newLevelDBDir.mkdirs() returns false. Dominant cause: the directory already exists (leftover from an earlier aborted snapshot/compress run); otherwise standard mkdirs failures (permissions, file in the way).

Common situations: Re-running a bootstrap-transfer after a previous attempt crashed midway, leaving aliasmap_snapshot/<bpid> behind; permission drift on the aliasmap parent; concurrent snapshot attempts by two processes.

Related errors


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