{"record":{"id":"64949b605a3bf4f0","repo":"apache/hadoop","slug":"failed-to-move-path-to-trash-trashpath","errorCode":null,"errorMessage":"Failed to move {path} to trash {trashPath}","messagePattern":"Failed to move (.+?) to trash (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/TrashPolicyDefault.java","lineNumber":202,"sourceCode":"      try {\n        // if the target path in Trash already exists, then append with \n        // a current time in millisecs.\n        String orig = trashPath.toString();\n        \n        while(fs.exists(trashPath)) {\n          trashPath = new Path(orig + Time.now());\n        }\n        \n        // move to current trash\n        fs.rename(path, trashPath,\n            Rename.TO_TRASH);\n        LOG.info(\"Moved: '\" + path + \"' to trash at: \" + trashPath);\n        return true;\n      } catch (IOException e) {\n        cause = e;\n      }\n    }\n    throw new IOException(\"Failed to move \" + path + \" to trash \" + trashPath,\n        cause);\n  }\n\n  @SuppressWarnings(\"deprecation\")\n  @Override\n  public void createCheckpoint() throws IOException {\n    createCheckpoint(new Date());\n  }\n\n  @SuppressWarnings(\"deprecation\")\n  public void createCheckpoint(Date date) throws IOException {\n    Collection<FileStatus> trashRoots = fs.getTrashRoots(false);\n    for (FileStatus trashRoot: trashRoots) {\n      LOG.info(\"TrashPolicyDefault#createCheckpoint for trashRoot: \" +\n          trashRoot.getPath());\n      createCheckpoint(trashRoot.getPath(), date);\n    }\n  }","sourceCodeStart":184,"sourceCodeEnd":220,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/TrashPolicyDefault.java#L184-L220","documentation":"Thrown by TrashPolicyDefault.moveToTrash after two failed attempts to move the path into the trash (mkdirs + rename into .Trash/Current, with a timestamp suffix retry inside the loop). The original cause - the IOException from the last fs.rename - is attached, so the message tells you what was being moved where, and getCause() tells you why.","triggerScenarios":"Trash directory not creatable (permissions on user home), quota exceeded at the trash destination, disk full on the volume holding .Trash, or a pre-existing target that could not be renamed over. The two-iteration loop exists to survive a concurrent checkpoint renaming Current underneath it; anything failing both times is fatal.","commonSituations":"User home quota exhausted before a big cleanup; trash root owned by another user after UID changes; shared clusters where .Trash perms were tightened; deleting during a concurrent expunge.","solutions":["Inspect the attached cause: AccessControlException -> fix .Trash ownership/permissions; QuotaExceededException -> raise quota or expunge; IOException disk full -> free space","Run 'hadoop fs -expunge' (or empty .Trash) to make room, then retry the delete","If the data must go now and trash is the blocker: re-run with -skipTrash after confirming permanent deletion is acceptable"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// preflight the trash destination before deleting\nPath trashRoot = fs.getTrashRoot(path);\nif (!fs.exists(trashRoot)) {\n  fs.mkdirs(trashRoot, new FsPermission((short)0700));\n}\n// let quota/permission failures surface now with a clear context\nfs.getFileStatus(trashRoot);","typeGuard":null,"tryCatchPattern":"try {\n  fs.delete(path, true);\n} catch (IOException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"Failed to move\")) {\n    Throwable c = e.getCause(); // real reason: perms, quota, disk full\n    // fix per cause, expunge trash, then retry once\n  }\n}","preventionTips":["Expunge trash and verify .Trash permissions/quota before large cleanup jobs","The policy already retries twice; a second identical failure means an environmental cause - inspect getCause() instead of looping"],"tags":["hadoop","trash","rename","quota"],"backgroundTag":"move-to-trash-failed","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}