{"record":{"id":"1dbf8147cd39b921","repo":"apache/hadoop","slug":"unknown","errorCode":"UNKNOWN","errorMessage":"Unknown error","messagePattern":"Unknown error","errorType":"exception","errorClass":"NativeIOException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/nativeio/NativeIO.java","lineNumber":403,"sourceCode":"    private static native Stat stat(String path) throws IOException;\n\n    /** Native chmod implementation. On UNIX, it is a wrapper around chmod(2) */\n    private static native void chmodImpl(String path, int mode) throws IOException;\n\n    public static void chmod(String path, int mode) throws IOException {\n      if (!Shell.WINDOWS) {\n        chmodImpl(path, mode);\n      } else {\n        try {\n          chmodImpl(path, mode);\n        } catch (NativeIOException nioe) {\n          if (nioe.getErrorCode() == 3) {\n            throw new NativeIOException(\"No such file or directory\",\n                Errno.ENOENT);\n          } else {\n            LOG.warn(String.format(\"NativeIO.chmod error (%d): %s\",\n                nioe.getErrorCode(), nioe.getMessage()));\n            throw new NativeIOException(\"Unknown error\", Errno.UNKNOWN);\n          }\n        }\n      }\n    }\n\n    /** Wrapper around posix_fadvise(2) */\n    static native void posix_fadvise(\n      FileDescriptor fd, long offset, long len, int flags) throws NativeIOException;\n\n    /** Wrapper around sync_file_range(2) */\n    static native void sync_file_range(\n      FileDescriptor fd, long offset, long nbytes, int flags) throws NativeIOException;\n\n    /**\n     * Call posix_fadvise on the given file descriptor. See the manpage\n     * for this syscall for more information. On systems where this\n     * call is not available, does nothing.\n     *","sourceCodeStart":385,"sourceCodeEnd":421,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/nativeio/NativeIO.java#L385-L421","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  NativeIO.chmod(path, mode);\n} catch (NativeIOException e) {\n  if (e.getErrno() == Errno.UNKNOWN) {\n    // consult the WARN log for the real Win32 code (5=access denied, 32=locked)\n    // retry after closing handles or fixing ACLs\n  } else { throw e; }\n}","preventionTips":["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."],"tags":["native-io","windows","chmod","unknown-error","win32"],"backgroundTag":"native-io-failure","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}