{"record":{"id":"269afc09696518b1","repo":"apache/hadoop","slug":"inmemoryaliasmap-location-is-null","errorCode":null,"errorMessage":"InMemoryAliasMap location is null","messagePattern":"InMemoryAliasMap location is null","errorType":"validation","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/aliasmap/InMemoryAliasMap.java","lineNumber":99,"sourceCode":"\n  @Override\n  public void setConf(Configuration conf) {\n    this.conf = conf;\n  }\n\n  @Override\n  public Configuration getConf() {\n    return this.conf;\n  }\n\n  public static @Nonnull InMemoryAliasMap init(Configuration conf,\n      String blockPoolID) throws IOException {\n    Options options = new Options();\n    options.createIfMissing(true);\n    String directory =\n        conf.get(DFSConfigKeys.DFS_PROVIDED_ALIASMAP_INMEMORY_LEVELDB_DIR);\n    if (directory == null) {\n      throw new IOException(\"InMemoryAliasMap location is null\");\n    }\n    File levelDBpath;\n    if (blockPoolID != null) {\n      levelDBpath = new File(directory, blockPoolID);\n    } else {\n      levelDBpath = new File(directory);\n    }\n    if (!levelDBpath.exists()) {\n      LOG.warn(\"InMemoryAliasMap location {} is missing. Creating it.\",\n          levelDBpath);\n      if(!levelDBpath.mkdirs()) {\n        throw new IOException(\n            \"Unable to create missing aliasmap location: \" + levelDBpath);\n      }\n    }\n    DB levelDb = JniDBFactory.factory.open(levelDBpath, options);\n    InMemoryAliasMap aliasMap =  new InMemoryAliasMap(levelDBpath.toURI(),\n        levelDb, blockPoolID);","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/aliasmap/InMemoryAliasMap.java#L81-L117","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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).","If you did not intend an in-memory aliasmap, remove/override dfs.provided.aliasmap.class so the InMemoryAliasMap is never constructed.","For multi-bpid setups the map appends the blockPoolID under that directory, so point it at a parent dir dedicated to aliasmaps.","Restart the NameNode/DN after the config change and confirm the LevelDB dir is created."],"exampleFix":"<!-- before -->\n<property>\n  <name>dfs.provided.aliasmap.class</name>\n  <value>org.apache.hadoop.hdfs.server.aliasmap.InMemoryAliasMap</value>\n</property>\n<!-- IOException: InMemoryAliasMap location is null -->\n\n<!-- after -->\n<property>\n  <name>dfs.provided.aliasmap.class</name>\n  <value>org.apache.hadoop.hdfs.server.aliasmap.InMemoryAliasMap</value>\n</property>\n<property>\n  <name>dfs.provided.aliasmap.inmemory.leveldb.dir</name>\n  <value>/data/aliasmap</value>\n</property>","handlingStrategy":"validation","validationCode":"String dir = conf.get(DFSConfigKeys.DFS_PROVIDED_ALIASMAP_INMEMORY_LEVELDB_DIR);\nif (dir == null) {\n  throw new IOException(\"Set dfs.provided.aliasmap.inmemory.leveldb.dir \"\n      + \"before using InMemoryAliasMap\");\n}\nInMemoryAliasMap aliasMap = InMemoryAliasMap.init(conf, blockPoolID);","typeGuard":null,"tryCatchPattern":"try {\n  aliasMap = InMemoryAliasMap.init(conf, bpid);\n} catch (IOException e) {\n  if (\"InMemoryAliasMap location is null\".equals(e.getMessage())) {\n    // config gap: set the leveldb dir key and restart; or switch aliasmap class\n    throw new ConfigurationException(DFSConfigKeys.DFS_PROVIDED_ALIASMAP_INMEMORY_LEVELDB_DIR);\n  } else { throw e; }\n}","preventionTips":["Pair dfs.provided.aliasmap.class=InMemoryAliasMap with dfs.provided.aliasmap.inmemory.leveldb.dir always.","Add a config lint rule that checks dependent keys are set together.","Pre-create the aliasmap directory with correct ownership during provisioning."],"tags":["hdfs","provided-storage","aliasmap","configuration","leveldb"],"backgroundTag":"missing-configuration","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}