{"record":{"id":"6cf258f8f30c2232","repo":"apache/hadoop","slug":"root-datanodeuuid-does-not-match-from-o","errorCode":null,"errorMessage":"Root {}: DatanodeUuid={}, does not match {} from other StorageDirectory.","messagePattern":"Root (.+?): DatanodeUuid=(.+?), does not match (.+?) from other StorageDirectory\\.","errorType":"exception","errorClass":"InconsistentFSStateException","httpStatus":null,"severity":"critical","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataStorage.java","lineNumber":668,"sourceCode":"    String sid = sd.getStorageUuid();\n    if (!(sid == null || sid.equals(\"\") ||\n          ssid.equals(\"\") || sid.equals(ssid))) {\n      throw new InconsistentFSStateException(sd.getRoot(),\n          \"has incompatible storage Id.\");\n    }\n\n    if (sid == null) { // update id only if it was null\n      sd.setStorageUuid(ssid);\n    }\n\n    // Update the datanode UUID if present.\n    if (props.getProperty(\"datanodeUuid\") != null) {\n      String dnUuid = props.getProperty(\"datanodeUuid\");\n\n      if (getDatanodeUuid() == null) {\n        setDatanodeUuid(dnUuid);\n      } else if (getDatanodeUuid().compareTo(dnUuid) != 0) {\n        throw new InconsistentFSStateException(sd.getRoot(),\n            \"Root \" + sd.getRoot() + \": DatanodeUuid=\" + dnUuid +\n            \", does not match \" + getDatanodeUuid() + \" from other\" +\n            \" StorageDirectory.\");\n      }\n    }\n  }\n\n  @Override\n  public boolean isPreUpgradableLayout(StorageDirectory sd) throws IOException {\n    File oldF = new File(sd.getRoot(), \"storage\");\n    if (!oldF.exists()) {\n      return false;\n    }\n    // check the layout version inside the storage file\n    // Lock and Read old storage file\n    try (RandomAccessFile oldFile = new RandomAccessFile(oldF, \"rws\");\n      FileLock oldLock = oldFile.getChannel().tryLock()) {\n      if (null == oldLock) {","sourceCodeStart":650,"sourceCodeEnd":686,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataStorage.java#L650-L686","documentation":"All storage directories of one datanode must carry the same datanodeUuid (the datanodeUuid property in each VERSION). If a directory's UUID differs from the one already loaded from another directory, InconsistentFSStateException names the root and both UUIDs, and the DN refuses to start with mixed-identity directories.","triggerScenarios":"Two or more dfs.datanode.data.dir entries whose VERSION files carry different datanodeUuid values - one dir copied from another node, or a dir formatted by a different DN while the others are original.","commonSituations":"Cloned/reused disks moved between nodes; adding a volume that once belonged to another datanode; disaster-recovery restores that mix directories of different origins; manual dir swaps between hosts.","solutions":["Identify the foreign directory by comparing the two UUIDs in the message with the DN's expected DatanodeUuid (JMX / NN page)","Remove the mismatched dir from dfs.datanode.data.dir, or wipe/reformat it so all dirs share one UUID","Never share or copy DN storage dirs between datanodes; let the owning DN format new volumes in place"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Compare datanodeUuid across all data dirs before starting the DN\nSet<String> uuids = new HashSet<>();\nfor (String dir : dataDirs) {\n  Path v = Paths.get(dir, \"current/VERSION\");\n  if (Files.exists(v)) {\n    String line = Files.readAllLines(v).stream()\n        .filter(l -> l.startsWith(\"datanodeUuid=\")).findFirst().orElse(null);\n    if (line != null) uuids.add(line.split(\"=\", 2)[1]);\n  }\n}\nif (uuids.size() > 1) throw new IOException(\"Mixed datanodeUuid in data dirs: \" + uuids);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["One datanode identity per directory set: never mix disks from different DNs in dfs.datanode.data.dir","When adding recycled disks, wipe or reformat them on the new owner first","Record each disk's datanodeUuid in hardware inventory during provisioning"],"tags":["hadoop","hdfs","datanode","storage","datanode-uuid","mismatch","startup"],"backgroundTag":"datanode-uuid-mismatch","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}