{"record":{"id":"9d12da356f2535bf","repo":"apache/hadoop","slug":"file-deletion-failed","errorCode":null,"errorMessage":"File deletion failed!","messagePattern":"File deletion failed!","errorType":"exception","errorClass":"DiskErrorException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ReadWriteDiskValidator.java","lineNumber":90,"sourceCode":"          System.nanoTime() - startTime, TimeUnit.NANOSECONDS);\n      metric.addReadFileLatency(readLatency);\n\n      // validation\n      if (!Arrays.equals(inputBytes, outputBytes)) {\n        metric.diskCheckFailed();\n        throw new DiskErrorException(\"Data in file has been corrupted.\");\n      }\n    } catch (IOException e) {\n      metric.diskCheckFailed();\n      throw new DiskErrorException(\"Disk Check failed!\", e);\n    } finally {\n      // delete the file\n      if (tmpFile != null) {\n        try {\n          Files.delete(tmpFile);\n        } catch (IOException e) {\n          metric.diskCheckFailed();\n          throw new DiskErrorException(\"File deletion failed!\", e);\n        }\n      }\n    }\n  }\n}\n","sourceCodeStart":72,"sourceCodeEnd":96,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ReadWriteDiskValidator.java#L72-L96","documentation":"The finally block of ReadWriteDiskValidator.checkStatus deletes the temp 'test*.tmp' file it created; if Files.delete throws IOException it also flags the failure metric and throws DiskErrorException(\"File deletion failed!\", e). The write/read probe itself may already have passed — the volume is penalized purely because cleanup failed, so this error isolates a deletion-specific fault.","triggerScenarios":"Filesystem switched to read-only between create and delete (auto-remount after an I/O error); immutable attribute (chattr +i) on the file; external processes holding locks on the file on Windows-style mounts; accumulated stale test*.tmp files.","commonSituations":"Volumes that flip ro mid-check on flaky disks; security tooling making files immutable; shared mounts where another agent recreates or locks temp files.","solutions":["Remove leftover test*.tmp files; lsattr them and chattr -i if immutable","Check /proc/mounts for an ro remount and repair the underlying disk/filesystem (dmesg shows the trigger)","Ensure no antivirus/backup agent locks files inside the checked directory","Restart the NodeManager and confirm DirectoryCollection re-marks the dir healthy"],"exampleFix":"# before\nlsattr /mnt/yarn/local/test*.tmp   # shows 'i' flag\n\n# after\nsudo chattr -i /mnt/yarn/local/test*.tmp && sudo rm -f /mnt/yarn/local/test*.tmp","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { diskValidator.checkStatus(dir); } catch (DiskErrorException e) { if (e.getMessage() != null && e.getMessage().contains(\"File deletion failed\")) { scheduleCleanup(dir, \"test*.tmp\"); } volume.markFailed(); }","preventionTips":["Periodically clean stale test*.tmp files from checked directories","Avoid chattr +i or external locks inside local dirs","Watch for read-only remounts (dmesg ext4/XFS errors) that surface first as deletion failures"],"tags":["hadoop","yarn","disk-check","temp-file","cleanup"],"backgroundTag":"temp-file-deletion-failed","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}