apache/hadoop · error · FileNotFoundException
rename destination parent ${parent} not found.
Error message
rename destination parent ${parent} not found. What it means
In the deprecated options-aware rename, when the destination does not exist its parent is stat'ed; a null parent status throws FileNotFoundException('rename destination parent parent not found.'). Rename never creates destination parents - that is mkdirs' job.
Source
Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java:1715
}
if (!overwrite) {
throw new FileAlreadyExistsException("rename destination " + dst
+ " already exists.");
}
// Delete the destination that is a file or an empty directory
if (dstStatus.isDirectory()) {
FileStatus[] list = listStatus(dst);
if (list != null && list.length != 0) {
throw new IOException(
"rename cannot overwrite non empty destination directory " + dst);
}
}
delete(dst, false);
} else {
final Path parent = dst.getParent();
final FileStatus parentStatus = getFileStatus(parent);
if (parentStatus == null) {
throw new FileNotFoundException("rename destination parent " + parent
+ " not found.");
}
if (!parentStatus.isDirectory()) {
throw new ParentNotDirectoryException("rename destination parent " + parent
+ " is a file.");
}
}
if (!rename(src, dst)) {
throw new IOException("rename from " + src + " to " + dst + " failed.");
}
}
/**
* Truncate the file in the indicated path to the indicated size.
* <ul>
* <li>Fails if path is a directory.</li>
* <li>Fails if path does not exist.</li>
* <li>Fails if path is not closed.</li>View on GitHub (pinned to 2add963021)
Solutions
- Call fs.mkdirs(dst.getParent()) before the rename
- Validate parent existence in publish preconditions and fail early with context
- Retry once after recreating parents if a concurrent cleaner may have interfered
Example fix
// before fs.rename(src, new Path(base, "dt=2026-08-22/part")); // parent 'dt=...' absent // after Path dst = new Path(base, "dt=2026-08-22/part"); fs.mkdirs(dst.getParent()); fs.rename(src, dst);
Defensive patterns
Strategy: validation
Validate before calling
Path parent = dst.getParent();
if (!fs.exists(parent)) {
fs.mkdirs(parent);
}
fs.rename(src, dst); Prevention
- Create destination parents as an explicit pipeline step
- Check parent existence in publish preconditions
- Watch for cleanup daemons that race publish steps
When it happens
Trigger: rename(src, dst) where dst's parent directory was never created or was concurrently removed - e.g. renaming into a new dated/partition subdirectory.
Common situations: Partitioned output layouts where the parent dir comes from an earlier step that failed; cleanup daemons racing the publish step.
Related errors
- Cannot overwrite an existing file: %s
- Cannot rename because path does not exist: %s
- destination has no parent
- Rename unsuccessful : '%s' to '%s'
- The source {src} and destination {dst} are the same
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/f24bda401cc86b9f.
Report an issue: GitHub.