apache/hadoop · error · IOException
Failed to copy {srcFile} to {destFile} due to failure in Nat
Error message
Failed to copy {srcFile} to {destFile} due to failure in NativeIO#copyFileUnbuffered(). {e} What it means
Storage.nativeCopyFileUnbuffered calls NativeIO.copyFileUnbuffered (sendfile/copy_file_range on Linux, CopyFile on Windows); a NativeIOException from that syscall is rewrapped here with both canonical paths and the original error text. The errno embedded in the message is the real diagnosis: ENOSPC (disk full), EIO (device error), EACCES, or ENOENT if the source vanished mid-copy.
Source
Thrown at hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/common/Storage.java:1363
throw new IOException("Destination '" + parentFile
+ "' directory cannot be created");
}
}
if (destFile.exists()) {
if (FileUtil.canWrite(destFile) == false) {
throw new IOException("Destination '" + destFile
+ "' exists but is read-only");
} else {
if (destFile.delete() == false) {
throw new IOException("Destination '" + destFile
+ "' exists but cannot be deleted");
}
}
}
try {
NativeIO.copyFileUnbuffered(srcFile, destFile);
} catch (NativeIOException e) {
throw new IOException("Failed to copy " + srcFile.getCanonicalPath()
+ " to " + destFile.getCanonicalPath()
+ " due to failure in NativeIO#copyFileUnbuffered(). "
+ e.toString());
}
if (srcFile.length() != destFile.length()) {
throw new IOException("Failed to copy full contents from '" + srcFile
+ "' to '" + destFile + "'");
}
if (preserveFileDate) {
if (destFile.setLastModified(srcFile.lastModified()) == false) {
LOG.debug("Failed to preserve last modified date from'{}' to '{}'",
srcFile, destFile);
}
}
}
/**
* Recursively delete all the content of the directory first and then View on GitHub (pinned to 2add963021)
Solutions
- Read the errno in the message: ENOSPC -> free space or enlarge the volume; EIO -> check dmesg/RAID health
- Retry the copy after resolving the transient cause (space freed, source stabilized)
- Ensure no concurrent process deletes or chmods the source during checkpointing
Defensive patterns
Strategy: retry
Validate before calling
long free = dst.getParentFile().getUsableSpace();
if (free > 0 && free < srcFile.length()) {
throw new IOException("insufficient space for copy: need " + srcFile.length() + ", have " + free);
} Try / catch
for (int i = 0; i < 3; i++) {
try {
Storage.nativeCopyFileUnbuffered(src, dst, true);
break;
} catch (IOException e) {
if (!isTransient(e.getMessage())) throw e; // ENOSPC/EACCES are not transient
sleepBackoff(i);
}
} Prevention
- Monitor free space on name/checkpoint volumes; ENOSPC (errno 28) is the most common cause
- Retry only genuinely transient errors (EIO on flaky hardware, brief races), never permission errors
- Keep antivirus and backup tools from holding storage files during checkpoints
When it happens
Trigger: Destination disk full (errno 28/ENOSPC); failing disk or controller (EIO); source removed by a concurrent process during the copy; permission revoked between the pre-checks and the syscall.
Common situations: Checkpoint image copies filling a small name-dir volume; dying disks during fsimage transfer; concurrent cleanup scripts deleting in-flight files.
Related errors
- Input/output error
- Disk Check failed!
- Cannot create directory {curDir}
- Failed to rename {from} to {to} due to failure in native ren
- Source must not be null
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/9badf51b11f092a0.
Report an issue: GitHub.