{"record":{"id":"778078e510cd5f68","repo":"apache/hadoop","slug":"datanode-id-mismatch","errorCode":"DATANODE_ID_MISMATCH","errorMessage":"Plan was generated for another node.","messagePattern":"Plan was generated for another node\\.","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":502,"sourceCode":"      }\n      String errorString = \"Plan was generated more than \" + planValidity\n          + \" ago\";\n      LOG.error(\"Disk Balancer - \" + errorString);\n      throw new DiskBalancerException(errorString,\n          DiskBalancerException.Result.OLD_PLAN_SUBMITTED);\n    }\n  }\n\n  /**\n   * Verify Node UUID.\n   *\n   * @param plan - Node Plan\n   */\n  private void verifyNodeUUID(NodePlan plan) throws DiskBalancerException {\n    if ((plan.getNodeUUID() == null) ||\n        !plan.getNodeUUID().equals(this.dataNodeUUID)) {\n      LOG.error(\"Disk Balancer - Plan was generated for another node.\");\n      throw new DiskBalancerException(\n          \"Plan was generated for another node.\",\n          DiskBalancerException.Result.DATANODE_ID_MISMATCH);\n    }\n  }\n\n  /**\n   * Convert a node plan to DiskBalancerWorkItem that Datanode can execute.\n   *\n   * @param plan - Node Plan\n   */\n  private void createWorkPlan(NodePlan plan) throws DiskBalancerException {\n    Preconditions.checkState(lock.isHeldByCurrentThread());\n\n    // Cleanup any residual work in the map.\n    workMap.clear();\n    Map<String, String> storageIDToVolBasePathMap =\n        getStorageIDToVolumeBasePathMap();\n","sourceCodeStart":484,"sourceCodeEnd":520,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DiskBalancer.java#L484-L520","documentation":"Every diskbalancer plan embeds the DataNode UUID it was computed for. verifyNodeUUID() rejects the submission with Result.DATANODE_ID_MISMATCH when plan.getNodeUUID() is null or does not equal the local DataNode's UUID. Volume-usage data in the plan is only meaningful on the node where it was measured.","triggerScenarios":"Submitting a plan generated by `hdfs diskbalancer -plan other-host:port` to this DataNode; a plan whose nodeUUID field was removed or blanked by hand-editing; a DataNode whose storage was reformatted so its Datanode UUID changed after the plan was generated.","commonSituations":"Automation that generates one plan and submits it to every DataNode; cluster re-format or data-dir wipe changing the datanode UUID; multi-homed hosts where hostname resolution differs between plan generation and submission.","solutions":["Regenerate the plan for this exact node: `hdfs diskbalancer -plan <this-host>:<ipc-port>` and submit that file.","Compare the plan's nodeID/nodeUUID with the DataNode's UUID (DataNode JMX or the VERSION file's datanodeUuid) to confirm the mismatch.","If the DataNode was reformatted, discard all old plans — they are permanently invalid for the new UUID.","Fix automation to generate a per-node plan instead of sharing one plan across nodes."],"exampleFix":"// before: reuse a plan generated for another DataNode\ndiskBalancer.submitPlan(planID, version, planString, false);\n\n// after: verify the plan targets this node first\nNodePlan p = NodePlan.parseJson(planString);\nif (p.getNodeUUID() == null || !p.getNodeUUID().equals(datanode.getDatanodeUuid())) {\n  planString = generateFreshPlan(datanode); // plan for THIS node\n}\ndiskBalancer.submitPlan(planID, version, planString, false);","handlingStrategy":"validation","validationCode":"NodePlan p = NodePlan.parseJson(planString);\nString localUuid = dataNode.getDatanodeUuid();\nif (p.getNodeUUID() == null || !p.getNodeUUID().equals(localUuid)) {\n  // plan targets a different DataNode: regenerate for this node\n}","typeGuard":null,"tryCatchPattern":"try {\n  diskBalancer.submitPlan(planID, version, plan, false);\n} catch (DiskBalancerException e) {\n  if (e.getResult() == DiskBalancerException.Result.DATANODE_ID_MISMATCH) {\n    // plan belongs to another node: regenerate locally, do not retry the same file\n  }\n}","preventionTips":["Name plan files with the target host and verify before submission","Discard all diskbalancer plans after reformatting a DataNode","Never share one plan file across multiple DataNodes"],"tags":["disk-balancer","datanode-uuid","plan-validation","hdfs"],"backgroundTag":"node-id-mismatch","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}