{"record":{"id":"48a8967e8c0abcc3","repo":"apache/hadoop","slug":"no-such-plan","errorCode":"NO_SUCH_PLAN","errorMessage":"No such plan.","messagePattern":"No such plan\\.","errorType":"exception","errorClass":"DiskBalancerException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DiskBalancer.java","lineNumber":276,"sourceCode":"  }\n\n  /**\n   * Cancels a running plan.\n   *\n   * @param planID - Hash of the plan to cancel.\n   * @throws DiskBalancerException\n   */\n  public void cancelPlan(String planID) throws DiskBalancerException {\n    lock.lock();\n    boolean needShutdown = false;\n    try {\n      checkDiskBalancerEnabled();\n      if (this.planID == null ||\n          !this.planID.equals(planID) ||\n          this.planID.isEmpty()) {\n        LOG.error(\"Disk Balancer - No such plan. Cancel plan failed. PlanID: \" +\n            planID);\n        throw new DiskBalancerException(\"No such plan.\",\n            DiskBalancerException.Result.NO_SUCH_PLAN);\n      }\n      if (!this.future.isDone()) {\n        this.currentResult = Result.PLAN_CANCELLED;\n        this.blockMover.setExitFlag();\n        scheduler.shutdown();\n        needShutdown = true;\n      }\n    } finally {\n      lock.unlock();\n    }\n    // no need to hold lock while shutting down executor.\n    if (needShutdown) {\n      shutdownExecutor();\n    }\n  }\n\n  /**","sourceCodeStart":258,"sourceCodeEnd":294,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DiskBalancer.java#L258-L294","documentation":"DiskBalancerException with Result.NO_SUCH_PLAN from DiskBalancer.cancelPlan: the cancel request names a planID that does not match the currently known plan - because this.planID is null (no plan ever submitted or node restarted), the submitted ID differs from the running one, or it is empty. Cancel only works against the single plan the DataNode currently holds.","triggerScenarios":"'hdfs diskbalancer -cancel <id>' with a stale or mistyped planID; cancel after the DataNode restarted (plan state is in-memory and lost); canceling a plan that already completed and was replaced by a null planID.","commonSituations":"Copy-pasting an old planID from a previous execution; canceling after DN restart (must re-submit, not cancel); canceling the wrong node's plan in federated/multi-DN scripts.","solutions":["Query the node for the actual running plan first: 'hdfs diskbalancer -query <datanode>' and read the PlanID field","Cancel using exactly that PlanID: 'hdfs diskbalancer -cancel <PlanID> -node <datanode>'","If the DataNode restarted, the old plan is gone - there is nothing to cancel; submit a fresh plan if rebalancing is still needed","If the plan already finished (query shows done/cancelled state), no cancel is required"],"exampleFix":"# before: cancel with stale ID -> NO_SUCH_PLAN\nhdfs diskbalancer -cancel 2016-...-old-plan-id\n\n# after: query the node, cancel the ID it actually holds\nhdfs diskbalancer -query <datanode>:<ipc_port>\n# PlanID: 3f9a...  PlanStatus: IN_PROGRESS\nhdfs diskbalancer -cancel 3f9a... -node <datanode>","handlingStrategy":"validation","validationCode":"// Resolve the live plan ID before canceling\n//   hdfs diskbalancer -query <datanode>\n// API sketch:\nString currentPlanId = diskBalancer.getPlanStatus().getPlanID();\nif (currentPlanId == null || currentPlanId.isEmpty()) {\n  // nothing to cancel - plan finished or DN restarted\n} else {\n  diskBalancer.cancelPlan(currentPlanId);\n}","typeGuard":null,"tryCatchPattern":"try {\n  diskBalancer.cancelPlan(requestedPlanId);\n} catch (DiskBalancerException e) {\n  if (e.getResult() == DiskBalancerException.Result.NO_SUCH_PLAN) {\n    // re-query the node for its actual PlanID (or accept that a restart\n    // cleared plan state and there is nothing to cancel)\n  }\n}","preventionTips":["Always -query the DataNode and copy the PlanID from that output when canceling","Remember DataNode restart discards in-memory plan state - old plan IDs cannot be canceled","Record the planID immediately after each -execute so operators cancel the right one later"],"tags":["hdfs","diskbalancer","cancel-plan","plan-id","dfsadmin"],"backgroundTag":"plan-not-found","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}