apache/hadoop · error · IOException
Could not create directory ${curDir}
Error message
Could not create directory ${curDir} What it means
SecondaryNameNode.ensureCurrentDirExists() verifies that the current/ subdirectory exists in every checkpoint storage directory before merging; if it does not exist and mkdirs() fails, an IOException with the concrete path is thrown and the checkpoint aborts. Unlike the startup checks, this fires mid-checkpoint when storage becomes unwritable between checkpoints.
Source
Thrown at hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/SecondaryNameNode.java:1052
void setMergeError() {
mergeErrorCount++;
}
void clearMergeError() {
mergeErrorCount = 0;
}
/**
* Ensure that the current/ directory exists in all storage
* directories
*/
void ensureCurrentDirExists() throws IOException {
for (Iterator<StorageDirectory> it
= storage.dirIterator(); it.hasNext();) {
StorageDirectory sd = it.next();
File curDir = sd.getCurrentDir();
if (!curDir.exists() && !curDir.mkdirs()) {
throw new IOException("Could not create directory " + curDir);
}
}
}
void deleteTempEdits() throws IOException {
FilenameFilter filter = new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return name.matches(NameNodeFile.EDITS_TMP.getName()
+ "_(\\d+)-(\\d+)_(\\d+)");
}
};
Iterator<StorageDirectory> it = storage.dirIterator(NameNodeDirType.EDITS);
for (;it.hasNext();) {
StorageDirectory dir = it.next();
File[] tempEdits = dir.getCurrentDir().listFiles(filter);
if (tempEdits != null) {
for (File t : tempEdits) {View on GitHub (pinned to 2add963021)
Solutions
- Check free space and mount health on every checkpoint volume (df -h <dir>) and clear space or remount rw
- Fix ownership/permissions on <checkpoint.dir>/current so the 2NN user can create it
- Remove any stray regular file named 'current' blocking directory creation
- Restart the SecondaryNameNode after repair; the next checkpoint cycle will recreate current/
Example fix
# before: current/ cannot be created $ ls -l /data/2nn/checkpoint total 0 -rw-r--r-- 1 root root 0 current # regular file shadowing the dir # after $ sudo rm /data/2nn/checkpoint/current && sudo -u hdfs hdfs secondarynamenode
Defensive patterns
Strategy: validation
Validate before calling
// before relying on checkpoint storage at runtime
for (Iterator<StorageDirectory> it = storage.dirIterator(); it.hasNext();) {
File cur = it.next().getCurrentDir();
if (!cur.exists()) {
File parent = cur.getParentFile();
if (!parent.canWrite()) {
throw new IOException("Cannot create " + cur + ": parent not writable");
}
}
} Try / catch
// the Checkpointer loop already catches IOException per cycle and retries at the
// next checkpoint interval — inspect cause, repair the volume, let it retry:
try {
secondaryNameNode.doCheckpoint();
} catch (IOException e) { // includes "Could not create directory <curDir>"
LOG.warn("Checkpoint failed, will retry: {}", e.getMessage());
} Prevention
- Disk-space and read-only-mount alerts on every checkpoint volume
- Regular test checkpoints (small checkpoint interval in staging) to surface storage rot early
- Keep ownership of <checkpoint.dir>/current consistent with the 2NN user in config management
When it happens
Trigger: sd.getCurrentDir() returns <checkpoint.dir>/current which is absent, and File.mkdirs() returns false — parent not writable, disk full, read-only filesystem remount, or a plain file named 'current' already occupying the path.
Common situations: Checkpoint disk fills up or goes read-only (failing disk, NFS soft-mount trouble) while the 2NN keeps running; permissions changed after a security hardening pass; a partially formatted directory left over from a crashed run.
Related errors
- checkpoint directory does not exist or is not accessible.
- Couldn't find image file at txid ${sig.mostRecentCheckpointT
- Cannot create directory {curDir}
- Image transfer servlet at " + url + " failed with status cod
- Unable to download to any storage directory
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/e6a64a5d467b37ff.
Report an issue: GitHub.