{"record":{"id":"0c98159dfb017e07","repo":"apache/hadoop","slug":"dir-is-not-a-directory","errorCode":null,"errorMessage":"dir + \" is not a directory!\"","messagePattern":"dir \\+ \" is not a directory!\"","errorType":"exception","errorClass":"DiskErrorException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ReadWriteDiskValidator.java","lineNumber":50,"sourceCode":" * ReadWriteDiskValidator is the class to check a directory by to create a file,\n * write some bytes into it, read back, and verify if they are identical.\n * Read time and write time are recorded and put into an\n * {@link ReadWriteDiskValidatorMetrics}.\n */\npublic class ReadWriteDiskValidator implements DiskValidator {\n\n  public static final String NAME = \"read-write\";\n  private static final Random RANDOM = new Random();\n\n  @Override\n  public void checkStatus(File dir) throws DiskErrorException {\n    ReadWriteDiskValidatorMetrics metric =\n        ReadWriteDiskValidatorMetrics.getMetric(dir.toString());\n    Path tmpFile = null;\n    try {\n      if (!dir.isDirectory()) {\n        metric.diskCheckFailed();\n        throw new DiskErrorException(dir + \" is not a directory!\");\n      }\n\n      // check the directory presence and permission.\n      DiskChecker.checkDir(dir);\n\n      // create a tmp file under the dir\n      tmpFile = Files.createTempFile(dir.toPath(), \"test\", \"tmp\");\n\n      // write 16 bytes into the tmp file\n      byte[] inputBytes = new byte[16];\n      RANDOM.nextBytes(inputBytes);\n      long startTime = System.nanoTime();\n      Files.write(tmpFile, inputBytes);\n      long writeLatency = TimeUnit.MICROSECONDS.convert(\n          System.nanoTime() - startTime, TimeUnit.NANOSECONDS);\n      metric.addWriteFileLatency(writeLatency);\n\n      // read back","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ReadWriteDiskValidator.java#L32-L68","documentation":"ReadWriteDiskValidator implements the 'read-write' disk check used through DiskValidatorFactory by the YARN NodeManager (yarn.nodemanager.disk-validator=read-write, applied to local-dirs/log-dirs via DirectoryCollection/LocalDirsHandlerService) and LocalDirAllocator. checkStatus(File dir) first verifies dir.isDirectory(); when the path is missing or is a plain file it increments the failure metric and throws DiskErrorException(dir + \" is not a directory!\").","triggerScenarios":"checkStatus on a configured local directory that does not exist or is a regular file; a mount that failed at boot so the configured path no longer resolves; a directory replaced by a file; a container/k8s environment where the path was never created.","commonSituations":"Typos in yarn.nodemanager.local-dirs / log-dirs or mapreduce.cluster.local.dir; hosts booting before network mounts are up; ops creating a placeholder file where the directory should be; UID/ownership changes making the dir inaccessible as a directory check target.","solutions":["mkdir -p the configured directory and chown it to the daemon's user (e.g. yarn)","Correct the local-dirs / log-dirs / mapreduce.cluster.local.dir path in config","Verify the mount is present (df, /proc/mounts) and the fstab entry mounts before the daemon starts","Restart the NodeManager so DirectoryCollection re-checks and marks the directory healthy"],"exampleFix":"# before: path missing or is a file\nls -ld /mnt/yarn/local   # missing or '-rw-r--r--'\n\n# after\nsudo mkdir -p /mnt/yarn/local && sudo chown yarn:yarn /mnt/yarn/local","handlingStrategy":"validation","validationCode":"File dir = new File(configuredPath);\nif (!dir.isDirectory()) {\n  throw new IllegalStateException(\"configured local dir is missing or not a directory: \" + dir);\n}","typeGuard":null,"tryCatchPattern":"try { diskValidator.checkStatus(dir); } catch (DiskErrorException e) { /* mark dir unhealthy, alert ops with e.getMessage() */ }","preventionTips":["Validate configured local dirs at daemon startup, not just during checks","Ensure mounts are up before the NodeManager starts (systemd dependencies)","Add config linting for local-dirs paths in deploy tooling"],"tags":["hadoop","yarn","disk-check","filesystem","configuration"],"backgroundTag":"configured-path-not-directory","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}