{"record":{"id":"87d208878dbb840d","repo":"apache/hadoop","slug":"cluster-id-is-incompatible-with-others","errorCode":null,"errorMessage":"cluster Id is incompatible with others.","messagePattern":"cluster Id is incompatible with others\\.","errorType":"exception","errorClass":"InconsistentFSStateException","httpStatus":null,"severity":"critical","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/common/StorageInfo.java","lineNumber":208,"sourceCode":"          + \" but StorageDirectory type=\" + type);\n    }\n  }\n  \n  /** Validate and set ctime from {@link Properties}*/\n  protected void setcTime(Properties props, StorageDirectory sd)\n      throws InconsistentFSStateException {\n    cTime = Long.parseLong(getProperty(props, sd, \"cTime\"));\n  }\n\n  /** Validate and set clusterId from {@link Properties}*/\n  protected void setClusterId(Properties props, int layoutVersion,\n      StorageDirectory sd) throws InconsistentFSStateException {\n    // Set cluster ID in version that supports federation\n    if (LayoutVersion.supports(getServiceLayoutFeatureMap(),\n        Feature.FEDERATION, layoutVersion)) {\n      String cid = getProperty(props, sd, \"clusterID\");\n      if (!(clusterID.equals(\"\") || cid.equals(\"\") || clusterID.equals(cid))) {\n        throw new InconsistentFSStateException(sd.getRoot(),\n            \"cluster Id is incompatible with others.\");\n      }\n      clusterID = cid;\n    }\n  }\n  \n  /** Validate and set layout version from {@link Properties}*/\n  protected void setLayoutVersion(Properties props, StorageDirectory sd)\n      throws IncorrectVersionException, InconsistentFSStateException {\n    int lv = Integer.parseInt(getProperty(props, sd, \"layoutVersion\"));\n    if (lv < getServiceLayoutVersion()) { // future version\n      throw new IncorrectVersionException(getServiceLayoutVersion(), lv,\n          \"storage directory \" + sd.root.getAbsolutePath());\n    }\n    layoutVersion = lv;\n  }\n  \n  /** Validate and set namespaceID version from {@link Properties}*/","sourceCodeStart":190,"sourceCodeEnd":226,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/common/StorageInfo.java#L190-L226","documentation":"StorageInfo.setClusterId runs when loading a storage directory on a federation-capable layout: the directory's clusterID must be empty (freshly formatted) or equal to the clusterID already loaded from earlier directories. Two different non-empty clusterIDs mean directories from different clusters are mixed in one daemon, which is unsafe, so InconsistentFSStateException is thrown.","triggerScenarios":"One of the configured storage directories was formatted against a different cluster (different clusterID than the rest); a leftover dir from a previous/test cluster left in dfs.namenode.name.dir or dfs.datanode.data.dir; a 2NN/BN bootstrap copied state from the wrong cluster.","commonSituations":"Docker/test clusters reusing volumes across reinstalls; adding a volume from a decommissioned cluster; reformatting the NameNode with a new clusterID while keeping old DataNode dirs.","solutions":["Identify the odd one out: cat <dir>/VERSION in every configured directory and compare clusterID","Wipe or reformat the mismatched directory with the running clusterID (hdfs namenode -format -clusterId <id> for NN; clear the block dirs for DN) - data in that dir is lost","Or simply remove the mismatched directory from the configuration list"],"exampleFix":"# before: dirs carry different clusterIDs\n# after: reformat the stray dir against the running cluster\nhdfs namenode -format -clusterId CID-20171105152119","handlingStrategy":"validation","validationCode":"Set<String> ids = new HashSet<>();\nfor (String d : configuredDirs) {\n  Properties p = Storage.readPropertiesFile(new File(d, \"VERSION\"));\n  String cid = p.getProperty(\"clusterID\");\n  if (cid != null && !cid.isEmpty()) ids.add(cid);\n}\nif (ids.size() > 1) throw new IOException(\"mixed clusterIDs in storage dirs: \" + ids);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Before joining a new storage dir to a daemon, verify its VERSION clusterID matches the running one","After reformatting a cluster, wipe stale dirs instead of leaving them in config","Script a startup preflight that compares clusterID across all configured directories"],"tags":["hdfs","cluster-id","storage","configuration","startup"],"backgroundTag":"cluster-id-mismatch","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}