{"record":{"id":"0d0209029c1a0d0c","repo":"apache/hadoop","slug":"unexepcted-blockpoolid-bpid-expected","errorCode":null,"errorMessage":"Unexepcted blockpoolID \" + bpid + \" . Expected \" + blockpoolID","messagePattern":"Unexepcted blockpoolID \" \\+ bpid \\+ \" \\. Expected \" \\+ blockpoolID","errorType":"exception","errorClass":"InconsistentFSStateException","httpStatus":null,"severity":"critical","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NNStorage.java","lineNumber":1059,"sourceCode":"    int rand = DFSUtil.getSecureRandom().nextInt(Integer.MAX_VALUE);\n    return \"BP-\" + rand + \"-\"+ ip + \"-\" + Time.now();\n  }\n\n  /** Validate and set block pool ID. */\n  public void setBlockPoolID(String bpid) {\n    blockpoolID = bpid;\n  }\n\n  /** Validate and set block pool ID. */\n  private void setBlockPoolID(File storage, String bpid)\n      throws InconsistentFSStateException {\n    if (bpid == null || bpid.equals(\"\")) {\n      throw new InconsistentFSStateException(storage, \"file \"\n          + Storage.STORAGE_FILE_VERSION + \" has no block pool Id.\");\n    }\n    \n    if (!blockpoolID.equals(\"\") && !blockpoolID.equals(bpid)) {\n      throw new InconsistentFSStateException(storage,\n          \"Unexepcted blockpoolID \" + bpid + \" . Expected \" + blockpoolID);\n    }\n    setBlockPoolID(bpid);\n  }\n  \n  public String getBlockPoolID() {\n    return blockpoolID;\n  }\n\n  /**\n   * Iterate over all current storage directories, inspecting them\n   * with the given inspector.\n   */\n  void inspectStorageDirs(FSImageStorageInspector inspector)\n      throws IOException {\n\n    // Process each of the storage directories to find the pair of\n    // newest image file and edit file","sourceCodeStart":1041,"sourceCodeEnd":1077,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NNStorage.java#L1041-L1077","documentation":"The same validator rejects a bpid that differs from the one already loaded: blockpoolID is set from the first directory read and every storage directory of the nameservice must agree, so 'Unexepcted blockpoolID <b> . Expected <e>' (the typo is in the Hadoop source) means directories from two different formats or clusters are mixed in one NameNode.","triggerScenarios":"One dfs.namenode.name.dir (or edits dir) belongs to another cluster/namespace - a disk reused from a different cluster, or only a subset of directories was reformatted during the last format.","commonSituations":"Reformatting only some dirs; attaching old data disks to a new NameNode; test clusters sharing storage across namespaces; swap-in of a dir from a twin cluster.","solutions":["Compare the blockpoolID= lines across all name/edits dirs' VERSION files; the odd one out came from another namespace.","Empty the offending dir (or reformat the whole cluster if disposable) so all dirs share one BP id - never mix dirs across namespaces.","If the mismatched dir holds real data, it belongs to the other cluster: mount it there instead."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Assert a single blockpoolID across all storage dirs before NN start\nSet<String> bpids = new HashSet<>();\nfor (String loc : conf.getTrimmedStrings(\"dfs.namenode.name.dir\")) {\n  bpids.add(parseVersion(Paths.get(stripScheme(loc), \"current\", \"VERSION\")).get(\"blockpoolID\"));\n}\nif (bpids.size() != 1 || bpids.contains(null)) {\n  throw new IllegalStateException(\"Mixed blockpoolIDs across name dirs: \" + bpids\n      + \" - a dir from another namespace is configured\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Wipe or reformat reused disks before adding them as name dirs.","During reformats, format all dirs in one operation so BP ids cannot diverge.","Diff blockpoolID= lines across dirs as part of pre-start checks."],"tags":["hdfs","namenode","storage","blockpool","clusterid"],"backgroundTag":"block-pool-id-mismatch","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}