apache/hadoop · error · IOException

InMemoryAliasMap location is null

Error message

InMemoryAliasMap location is null

What it means

InMemoryAliasMap.init throws IOException when dfs.provided.aliasmap.inmemory.leveldb.dir is unset (conf.get returns null) while an InMemoryAliasMap is being initialized. The InMemoryAliasMap is the LevelDB-backed block->provided-storage mapping used by HDFS with provided storage (dfs.provided.aliasmap.class=InMemoryAliasMap); it needs a concrete directory to open/create its LevelDB store.

Source

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

  @Override
  public void setConf(Configuration conf) {
    this.conf = conf;
  }

  @Override
  public Configuration getConf() {
    return this.conf;
  }

  public static @Nonnull InMemoryAliasMap init(Configuration conf,
      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);

View on GitHub (pinned to 2add963021)

Solutions

  1. Set the directory in hdfs-site.xml: dfs.provided.aliasmap.inmemory.leveldb.dir=/path/to/aliasmap (absolute path with write permission for the NN/DN user).
  2. If you did not intend an in-memory aliasmap, remove/override dfs.provided.aliasmap.class so the InMemoryAliasMap is never constructed.
  3. For multi-bpid setups the map appends the blockPoolID under that directory, so point it at a parent dir dedicated to aliasmaps.
  4. Restart the NameNode/DN after the config change and confirm the LevelDB dir is created.

Example fix

<!-- before -->
<property>
  <name>dfs.provided.aliasmap.class</name>
  <value>org.apache.hadoop.hdfs.server.aliasmap.InMemoryAliasMap</value>
</property>
<!-- IOException: InMemoryAliasMap location is null -->

<!-- after -->
<property>
  <name>dfs.provided.aliasmap.class</name>
  <value>org.apache.hadoop.hdfs.server.aliasmap.InMemoryAliasMap</value>
</property>
<property>
  <name>dfs.provided.aliasmap.inmemory.leveldb.dir</name>
  <value>/data/aliasmap</value>
</property>
Defensive patterns

Strategy: validation

Validate before calling

String dir = conf.get(DFSConfigKeys.DFS_PROVIDED_ALIASMAP_INMEMORY_LEVELDB_DIR);
if (dir == null) {
  throw new IOException("Set dfs.provided.aliasmap.inmemory.leveldb.dir "
      + "before using InMemoryAliasMap");
}
InMemoryAliasMap aliasMap = InMemoryAliasMap.init(conf, blockPoolID);

Try / catch

try {
  aliasMap = InMemoryAliasMap.init(conf, bpid);
} catch (IOException e) {
  if ("InMemoryAliasMap location is null".equals(e.getMessage())) {
    // config gap: set the leveldb dir key and restart; or switch aliasmap class
    throw new ConfigurationException(DFSConfigKeys.DFS_PROVIDED_ALIASMAP_INMEMORY_LEVELDB_DIR);
  } else { throw e; }
}

Prevention

When it happens

Trigger: InMemoryAliasMap.init(conf, blockPoolID) runs (Namenode bootstrap or DN ProvidedVolume init) with dfs.provided.aliasmap.inmemory.leveldb.dir absent from the configuration — the aliasmap class was configured but its storage directory key was not.

Common situations: Adopting HDFS provided storage (data on S3/HDFS mount) and configuring only dfs.provided.aliasmap.class; a hdfs-site.xml that ships defaults but omits the leveldb dir; porting a config from a cluster that used a remote aliasmap (RpcAliasMap) to InMemoryAliasMap without adding the dir key.

Related errors


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