apache/hadoop · error · IOException

Cannot remove current alias map: ${aliasMapFile}

Error message

Cannot remove current alias map: ${aliasMapFile}

What it means

During aliasmap bootstrap, after the user confirms formatting, BootstrapStandby calls FileUtil.fullyDelete(aliasMapFile) to clear the existing LevelDB aliasmap directory; if deletion fails it throws IOException with the path. The old aliasmap store could not be removed before re-downloading it.

Source

Thrown at hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ha/BootstrapStandby.java:559

   * @throws IOException
   */
  private int formatAndDownloadAliasMap(String pathAliasMap,
      RemoteNameNodeInfo proxyInfo) throws IOException {
    LOG.info("Bootstrapping the InMemoryAliasMap from "
        + proxyInfo.getHttpAddress());
    if (pathAliasMap == null) {
      throw new IOException("InMemoryAliasMap enabled with null location");
    }
    File aliasMapFile = new File(pathAliasMap);
    if (aliasMapFile.exists()) {
      AliasMapStorageDirectory aliasMapSD =
          new AliasMapStorageDirectory(aliasMapFile);
      if (!Storage.confirmFormat(
          Arrays.asList(aliasMapSD), force, interactive)) {
        return ERR_CODE_ALREADY_FORMATTED;
      } else {
        if (!FileUtil.fullyDelete(aliasMapFile)) {
          throw new IOException(
              "Cannot remove current alias map: " + aliasMapFile);
        }
      }
    }

    // create the aliasmap location.
    if (!aliasMapFile.mkdirs()) {
      throw new IOException("Cannot create directory " + aliasMapFile);
    }
    TransferFsImage.downloadAliasMap(proxyInfo.getHttpAddress(), aliasMapFile,
        true);
    return 0;
  }

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

View on GitHub (pinned to 2add963021)

Solutions

  1. Stop the NameNode/any process using the aliasmap directory (LevelDB holds a LOCK file) before bootstrapping
  2. chown -R <hdfs-user> <aliasmap.dir> and remove read-only bits, or delete the directory manually as the right user
  3. Verify the volume is writable and healthy, then re-run 'hdfs namenode -bootstrapStandby -force'

Example fix

# before: leftover aliasmap owned by root, delete fails
$ sudo -u hdfs hdfs namenode -bootstrapStandby -force
IOException: Cannot remove current alias map: /data/dfs/aliasmap/inmemory
# after
$ sudo chown -R hdfs:hadoop /data/dfs/aliasmap/inmemory
$ sudo -u hdfs hdfs namenode -bootstrapStandby -force
Defensive patterns

Strategy: validation

Validate before calling

File alias = new File(conf.get("dfs.provided.aliasmap.inmemory.leveldb.dir"));
if (alias.exists()) {
  if (!Files.isWritable(alias.toPath())) {
    throw new IOException("Aliasmap dir not deletable: fix ownership of " + alias);
  }
  if (new File(alias, "LOCK").exists()) {
    throw new IOException("A process still holds " + alias + "/LOCK — stop it first");
  }
}

Try / catch

try {
  runner.run(argv);
} catch (IOException e) { // "Cannot remove current alias map: <path>"
  // fix ownership / stop the holder of the LevelDB dir, then re-run with -force
}

Prevention

When it happens

Trigger: formatAndDownloadAliasMap() on a standby whose aliasmap dir already exists: fullyDelete fails because files are read-only, owned by another user, still held open by a running process (LevelDB lock file), or the filesystem is read-only.

Common situations: Re-running -bootstrapStandby while the standby NameNode/aliasmap process is still up holding the LEVELDB LOCK; aliasmap files owned by root from a previous manual operation; read-only or failing disk.

Related errors


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