{"record":{"id":"47c7f366f01f61cc","repo":"apache/hadoop","slug":"failed-move-src-to-trash","errorCode":null,"errorMessage":"Failed move {src} to trash.","messagePattern":"Failed move (.+?) to trash\\.","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-tools/hadoop-federation-balance/src/main/java/org/apache/hadoop/tools/fedbalance/TrashProcedure.java","lineNumber":77,"sourceCode":"\n  @Override\n  public boolean execute() throws IOException {\n    moveToTrash();\n    return true;\n  }\n\n  /**\n   * Delete source path to trash.\n   */\n  void moveToTrash() throws IOException {\n    Path src = context.getSrc();\n    if (srcFs.exists(src)) {\n      TrashOption trashOption = context.getTrashOpt();\n      switch (trashOption) {\n      case TRASH:\n        conf.setFloat(FS_TRASH_INTERVAL_KEY, 60);\n        if (!Trash.moveToAppropriateTrash(srcFs, src, conf)) {\n          throw new IOException(\"Failed move \" + src + \" to trash.\");\n        }\n        break;\n      case DELETE:\n        if (!srcFs.delete(src, true)) {\n          throw new IOException(\"Failed delete \" + src);\n        }\n        LOG.info(\"{} is deleted.\", src);\n        break;\n      case SKIP:\n        break;\n      default:\n        throw new IOException(\"Unexpected trash option=\" + trashOption);\n      }\n    }\n  }\n\n  public FedBalanceContext getContext() {\n    return context;","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-tools/hadoop-federation-balance/src/main/java/org/apache/hadoop/tools/fedbalance/TrashProcedure.java#L59-L95","documentation":"TrashProcedure.moveToTrash() is the final stage of a fedbalance job: after the data is safely on dst, it disposes of src per the trash option. For TRASH it forcibly sets fs.trash.interval=60 and calls Trash.moveToAppropriateTrash(srcFs, src, conf); a false return (a silent failure, not an exception) becomes this IOException. The copy itself already succeeded - only source cleanup failed.","triggerScenarios":"Trash.moveToAppropriateTrash(...) returns false: commonly the source FileSystem does not support/permit trash for that path, the user's .Trash area is not creatable/writable, or the trash move silently fails. Happens with -trash option (default) once the balance copy completed.","commonSituations":"The balance user has no writable home/.Trash on the src cluster; src on a filesystem that does not implement trash; the src path renamed/removed concurrently between exists() and the move.","solutions":["Check the balance user can write the trash area on the src cluster (try 'hdfs dfs -mkdir /user/<u>/.Trash').","Confirm src sits on HDFS (a ChecksumFileSystem); other filesystems may not support trash semantics.","If trash keeps failing, rerun with a different disposal option (-delete or -skip) instead of trash.","Once dst is verified complete, remove src manually ('hdfs dfs -rm -r' with or without trash)."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  // trash disposal stage of TrashProcedure / FedBalance run\n} catch (IOException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"to trash\")) {\n    // data already copied to dst; check .Trash writability or rerun with -delete/-skip, or rm src manually\n  }\n}","preventionTips":["Verify the balance user can write /user/<u>/.Trash on the src cluster before enabling the trash option.","Prefer the -delete option for unattended pipelines where trash semantics are not guaranteed."],"tags":["fedbalance","federation-balance","hdfs-trash","cleanup","source-deletion"],"backgroundTag":"hdfs-trash-move-failed","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}