apache/hadoop · error · IOException

Unable to create " + dbFile

Error message

Unable to create " + dbFile

What it means

For writers, createDB first ensures the target directory (levelDBPath, optionally with blockPoolID appended) exists; if File.mkdirs() returns false — permission denied, a regular file occupying the path, read-only filesystem, or missing ancestors — this IOException names the directory it could not create.

Source

Thrown at hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/common/blockaliasmap/impl/LevelDBFileRegionAliasMap.java:118

  private static DB createDB(String levelDBPath, boolean createIfMissing,
      String blockPoolID) throws IOException {
    if (levelDBPath == null || levelDBPath.length() == 0) {
      throw new IllegalArgumentException(
          "A valid path needs to be specified for "
              + LevelDBFileRegionAliasMap.class + " using the parameter "
              + DFS_PROVIDED_ALIASMAP_LEVELDB_PATH);
    }
    org.iq80.leveldb.Options options = new org.iq80.leveldb.Options();
    options.createIfMissing(createIfMissing);
    File dbFile;
    if (blockPoolID != null) {
      dbFile = new File(levelDBPath, blockPoolID);
    } else {
      dbFile = new File(levelDBPath);
    }
    if (createIfMissing && !dbFile.exists()) {
      if (!dbFile.mkdirs()) {
        throw new IOException("Unable to create " + dbFile);
      }
    }
    return factory.open(dbFile, options);
  }

  @Override
  public void refresh() throws IOException {
  }

  @Override
  public void close() throws IOException {
    // Do nothing.
  }

  /**
   * Class specifying reader options for the {@link LevelDBFileRegionAliasMap}.
   */
  public static class LevelDBOptions implements LevelDBReader.Options,

View on GitHub (pinned to 2add963021)

Solutions

  1. Check permissions along the whole path and chown/chmod the alias map root for the running user
  2. Ensure no regular file occupies the directory path; remove or relocate it
  3. Verify the filesystem is mounted read-write and has free space (df -h)

Example fix

# before
ls -l /hdfs/provided/aliasmap   # regular file or unwritable dir

# after
rm -f /hdfs/provided/aliasmap
mkdir -p /hdfs/provided/aliasmap && chown hdfs:hdfs /hdfs/provided/aliasmap
Defensive patterns

Strategy: validation

Validate before calling

Path dbDir = blockPoolID != null
    ? Paths.get(levelDBPath, blockPoolID) : Paths.get(levelDBPath);
if (Files.exists(dbDir) && !Files.isDirectory(dbDir)) {
  throw new IllegalStateException("Path occupied by a file: " + dbDir);
}
Files.createDirectories(dbDir); // throws with a clear cause if not permitted
if (!Files.isWritable(dbDir)) {
  throw new IllegalStateException("Alias map dir not writable: " + dbDir);
}

Prevention

When it happens

Trigger: The leveldb path's parent is not writable by the process, the path exists as a regular file, the volume is read-only or full, or another process concurrently manipulates the directory.

Common situations: DN running as a user without write access to dfs.provided.aliasmap.leveldb.path; a stale file left where the directory should be; volume mounted read-only after an fs error.

Related errors


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