{"record":{"id":"000d7f24443a3c46","repo":"apache/hadoop","slug":"incompatible-node-types-storagetype-storagetype","errorCode":null,"errorMessage":"Incompatible node types: storageType={storageType} but StorageDirectory type={type}","messagePattern":"Incompatible node types: storageType=(.+?) but StorageDirectory type=(.+?)","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":188,"sourceCode":"    if (props == null) {\n      return;\n    }\n    setLayoutVersion(props, sd);\n    setNamespaceID(props, sd);\n    setcTime(props, sd);\n    setClusterId(props, layoutVersion, sd);\n    checkStorageType(props, sd);\n  }\n  \n  /** Validate and set storage type from {@link Properties}*/\n  protected void checkStorageType(Properties props, StorageDirectory sd)\n      throws InconsistentFSStateException {\n    if (storageType == null) { //don't care about storage type\n      return;\n    }\n    NodeType type = NodeType.valueOf(getProperty(props, sd, \"storageType\"));\n    if (!storageType.equals(type)) {\n      throw new InconsistentFSStateException(sd.root,\n          \"Incompatible node types: storageType=\" + storageType\n          + \" 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\");","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/common/StorageInfo.java#L170-L206","documentation":"StorageInfo.checkStorageType reads the storageType property from a directory's VERSION file and compares it with the NodeType the current daemon expects (NAME_NODE vs DATA_NODE). A mismatch throws InconsistentFSStateException, because NameNode and DataNode storage layouts are incompatible. When the daemon's expected storageType is null it skips the check entirely.","triggerScenarios":"A DataNode configured with dfs.datanode.data.dir pointing at a NameNode's storage directory (or the reverse); a directory shared between both node types; a directory formatted by one daemon type then handed to the other via config copy-paste.","commonSituations":"Copy-pasted hdfs-site.xml between NN and DN roles; test/docker setups reusing one volume for every role; a typo listing the NN dir in the DN data-dir setting.","solutions":["Give each daemon role its own storage directories - never overlap dfs.namenode.name.dir and dfs.datanode.data.dir","Inspect <dir>/VERSION to see which node type formatted it (storageType property) and reassign the directory accordingly","If the directory was mis-formatted and its contents are disposable, wipe it and let the correct daemon format it on startup"],"exampleFix":"<!-- before: DataNode pointed at the NameNode dir -->\n<property><name>dfs.datanode.data.dir</name><value>/data/nn</value></property>\n<!-- after -->\n<property><name>dfs.datanode.data.dir</name><value>/data/dn</value></property>","handlingStrategy":"validation","validationCode":"Properties p = Storage.readPropertiesFile(new File(dir, \"VERSION\"));\nString diskType = p.getProperty(\"storageType\");\nif (diskType != null && !diskType.equals(expectedNodeType.name())) {\n  throw new IOException(dir + \" belongs to a \" + diskType + \"; refusing to use it as \"\n      + expectedNodeType);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Lint storage-dir configurations: NN and DN dir lists must be disjoint","Check the storageType property in a directory's VERSION before assigning it to a daemon role","Use role-specific config templates for NameNode and DataNode hosts"],"tags":["hdfs","storage","configuration","namenode","datanode","startup"],"backgroundTag":"storage-type-mismatch","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}