apache/hadoop · error · NativeIOException
UNKNOWN
UNKNOWN
Error message
Unknown error
What it means
The catch-all branch of NativeIO.chmod on Windows: any NativeIOException whose Win32 code is not 3 is WARN-logged as 'NativeIO.chmod error (N): message' and re-thrown as NativeIOException("Unknown error", Errno.UNKNOWN). The real cause survives only in the log line, not in the exception — you must correlate with the WARN entry.
Source
Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/nativeio/NativeIO.java:403
private static native Stat stat(String path) throws IOException;
/** Native chmod implementation. On UNIX, it is a wrapper around chmod(2) */
private static native void chmodImpl(String path, int mode) throws IOException;
public static void chmod(String path, int mode) throws IOException {
if (!Shell.WINDOWS) {
chmodImpl(path, mode);
} else {
try {
chmodImpl(path, mode);
} catch (NativeIOException nioe) {
if (nioe.getErrorCode() == 3) {
throw new NativeIOException("No such file or directory",
Errno.ENOENT);
} else {
LOG.warn(String.format("NativeIO.chmod error (%d): %s",
nioe.getErrorCode(), nioe.getMessage()));
throw new NativeIOException("Unknown error", Errno.UNKNOWN);
}
}
}
}
/** Wrapper around posix_fadvise(2) */
static native void posix_fadvise(
FileDescriptor fd, long offset, long len, int flags) throws NativeIOException;
/** Wrapper around sync_file_range(2) */
static native void sync_file_range(
FileDescriptor fd, long offset, long nbytes, int flags) throws NativeIOException;
/**
* Call posix_fadvise on the given file descriptor. See the manpage
* for this syscall for more information. On systems where this
* call is not available, does nothing.
*View on GitHub (pinned to 2add963021)
Solutions
- Read the accompanying WARN log 'NativeIO.chmod error (N)' and decode N as a Win32 error (5=access denied, 32=sharing violation, 87=invalid parameter).
- Fix the underlying condition: close competing handles/retry for 32; grant ACL rights or run with adequate privileges for 5; validate the mode bits for 87.
- For transient locks (AV scans), retry after a short delay rather than failing the operation.
Defensive patterns
Strategy: try-catch
Try / catch
try {
NativeIO.chmod(path, mode);
} catch (NativeIOException e) {
if (e.getErrno() == Errno.UNKNOWN) {
// consult the WARN log for the real Win32 code (5=access denied, 32=locked)
// retry after closing handles or fixing ACLs
} else { throw e; }
} Prevention
- Ensure the process owns adequate rights on the file before chmod.
- Close all open handles/streams before chmod on Windows.
- Keep org.apache.hadoop.io.nativeio at WARN+ so the real error code is always recorded.
When it happens
Trigger: chmod failing on Windows with an error other than path-not-found: 5 (ERROR_ACCESS_DENIED), 32 (ERROR_SHARING_VIOLATION — file locked by another process), 87 (ERROR_INVALID_PARAMETER), typically under mandatory Windows locks, restrictive ACLs, or an invalid mode argument.
Common situations: File held open by antivirus/indexer/another process; daemon user lacking permission to change attributes; read-only directories; chmod attempted on a file the process has no handle rights over.
Related errors
- ENOENT
- EBADF
- Could not rename temporary file {} to {} due to failure in n
- threadCreate: CreateThread failed with error %d
- threadJoin: WaitForSingleObject failed with error %d
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/1dbf8147cd39b921.
Report an issue: GitHub.