apache/hadoop · error · IOException

Unable to create missing aliasmap location: {levelDBpath}

Error message

Unable to create missing aliasmap location: {levelDBpath}

What it means

InMemoryAliasMap.init throws IOException when the resolved LevelDB path does not exist and File.mkdirs() fails to create it. After confirming dfs.provided.aliasmap.inmemory.leveldb.dir is set, Hadoop tries to create the missing directory tree (optionally with the blockPoolID appended); mkdirs() returning false means the FS refused creation — no permission on a parent, a parent that is a regular file, a read-only mount, or the path already existing as a file.

Source

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

      String blockPoolID) throws IOException {
    Options options = new Options();
    options.createIfMissing(true);
    String directory =
        conf.get(DFSConfigKeys.DFS_PROVIDED_ALIASMAP_INMEMORY_LEVELDB_DIR);
    if (directory == null) {
      throw new IOException("InMemoryAliasMap location is null");
    }
    File levelDBpath;
    if (blockPoolID != null) {
      levelDBpath = new File(directory, blockPoolID);
    } else {
      levelDBpath = new File(directory);
    }
    if (!levelDBpath.exists()) {
      LOG.warn("InMemoryAliasMap location {} is missing. Creating it.",
          levelDBpath);
      if(!levelDBpath.mkdirs()) {
        throw new IOException(
            "Unable to create missing aliasmap location: " + levelDBpath);
      }
    }
    DB levelDb = JniDBFactory.factory.open(levelDBpath, options);
    InMemoryAliasMap aliasMap =  new InMemoryAliasMap(levelDBpath.toURI(),
        levelDb, blockPoolID);
    aliasMap.setConf(conf);
    return aliasMap;
  }

  @VisibleForTesting
  InMemoryAliasMap(URI aliasMapURI, DB levelDb, String blockPoolID) {
    this.aliasMapURI = aliasMapURI;
    this.levelDb = levelDb;
    this.blockPoolID = blockPoolID;
  }

  @Override

View on GitHub (pinned to 2add963021)

Solutions

  1. Verify and fix permissions/ownership of the whole parent chain: mkdir -p + chown to the Hadoop service user, ensure rwx for that user on every parent.
  2. Check that nothing (file, symlink loop) already occupies the exact path; remove/relocate it.
  3. Confirm the filesystem is mounted read-write and has space/inodes (mount, df -h, df -i).
  4. Pick a directory on local persistent storage (not a read-only share) for dfs.provided.aliasmap.inmemory.leveldb.dir and restart.

Example fix

# before
# IOException: Unable to create missing aliasmap location: /data/aliasmap/BP-1234
sudo ls -ld /data/aliasmap   # owned by root, drwxr-xr-x

# after
sudo chown -R hdfs:hadoop /data/aliasmap
sudo chmod 755 /data/aliasmap
# restart NameNode; LevelDB store is created on init
Defensive patterns

Strategy: validation

Validate before calling

String dir = conf.get(DFSConfigKeys.DFS_PROVIDED_ALIASMAP_INMEMORY_LEVELDB_DIR);
File target = bpid != null ? new File(dir, bpid) : new File(dir);
File parent = target.getParentFile();
if (!target.exists() && !(parent.exists() && parent.canWrite())) {
  throw new IOException("Aliasmap parent not writable: " + parent);
}
InMemoryAliasMap.init(conf, bpid);

Try / catch

try {
  aliasMap = InMemoryAliasMap.init(conf, bpid);
} catch (IOException e) {
  if (e.getMessage() != null && e.getMessage().startsWith("Unable to create missing aliasmap")) {
    // fix perms on the parent chain, then retry init once
    ensureWritable(parentChain(target));
    aliasMap = InMemoryAliasMap.init(conf, bpid);
  } else { throw e; }
}

Prevention

When it happens

Trigger: init(conf, bpid) computes levelDBpath = <leveldb.dir>[/<bpid>], finds !exists(), and levelDBpath.mkdirs() returns false. Typical causes: parent dir not writable by the NN/DN user, path occupied by a file, NFS read-only export, or disk-full/inode-exhausted filesystem.

Common situations: Aliasmap directory configured under a path owned by root or another user; leftover regular file where the directory should be; containerized NameNode with an unmounted/RO volume at that path; SELinux/AppArmor denying writes.

Related errors


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