{"record":{"id":"18ef63437876f52a","repo":"apache/hadoop","slug":"namespaceid-is-incompatible-with-others","errorCode":null,"errorMessage":"namespaceID is incompatible with others.","messagePattern":"namespaceID 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":231,"sourceCode":"  }\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}*/\n  protected void setNamespaceID(Properties props, StorageDirectory sd)\n      throws InconsistentFSStateException {\n    int nsId = Integer.parseInt(getProperty(props, sd, \"namespaceID\"));\n    if (namespaceID != 0 && nsId != 0 && namespaceID != nsId) {\n      throw new InconsistentFSStateException(sd.root,\n          \"namespaceID is incompatible with others.\");\n    }\n    namespaceID = nsId;\n  }\n\n  public void setServiceLayoutVersion(int lv) {\n    this.layoutVersion = lv;\n  }\n\n  public int getServiceLayoutVersion() {\n    return storageType == NodeType.DATA_NODE\n        ? DataNodeLayoutVersion.getCurrentLayoutVersion()\n        : HdfsServerConstants.NAMENODE_LAYOUT_VERSION;\n  }\n\n  public Map<Integer, SortedSet<LayoutFeature>> getServiceLayoutFeatureMap() {\n    return storageType == NodeType.DATA_NODE? DataNodeLayoutVersion.FEATURES\n        : NameNodeLayoutVersion.FEATURES;","sourceCodeStart":213,"sourceCodeEnd":249,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/common/StorageInfo.java#L213-L249","documentation":"StorageInfo.setNamespaceID compares the namespaceID in the directory's VERSION with the namespaceID already loaded: if both are non-zero and differ, the directories belong to different namespaces and InconsistentFSStateException is thrown. An empty namespaceID is not permitted here (getProperty would already have failed on a missing key), so the mismatch is always a real conflict.","triggerScenarios":"Mixing a freshly formatted storage directory (new namespaceID) with directories of an existing namespace; a DataNode dir from a different namespace left in the config; NameNode was reformatted but DataNode dirs were not cleared.","commonSituations":"Adding a newly formatted volume to an existing set of storage dirs; reformatting the NameNode in a test loop without wiping DN storage; restoring one dir from another cluster's backup.","solutions":["Compare namespaceID across <dir>/VERSION files of all configured directories to find the mismatched one","Remove the mismatched directory from the configuration, or wipe/reformat it so it adopts the running namespace","After reformatting a NameNode, also clear DataNode storage directories so namespaceIDs realign on re-registration"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"Set<Integer> ids = new HashSet<>();\nfor (String d : configuredDirs) {\n  Properties p = Storage.readPropertiesFile(new File(d, \"VERSION\"));\n  int nsId = Integer.parseInt(p.getProperty(\"namespaceID\"));\n  if (nsId != 0) ids.add(nsId);\n}\nif (ids.size() > 1) throw new IOException(\"mixed namespaceIDs in storage dirs: \" + ids);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["When adding a volume to an existing namespace, format/wipe it first so it adopts the running namespaceID","After reformatting a NameNode, clear DataNode storage directories too","Preflight-compare namespaceID across all configured dirs at daemon startup"],"tags":["hdfs","namespace-id","storage","configuration","startup"],"backgroundTag":"namespace-id-mismatch","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}