{"record":{"id":"63647d4c1ad5950b","repo":"apache/hadoop","slug":"file-version-is-invalid","errorCode":null,"errorMessage":"file VERSION is invalid.","messagePattern":"file VERSION is invalid\\.","errorType":"exception","errorClass":"InconsistentFSStateException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BlockPoolSliceStorage.java","lineNumber":329,"sourceCode":"\n  /**\n   * Set layoutVersion, namespaceID and blockpoolID into block pool storage\n   * VERSION file\n   */\n  @Override\n  protected void setPropertiesFromFields(Properties props, StorageDirectory sd)\n      throws IOException {\n    props.setProperty(\"layoutVersion\", String.valueOf(layoutVersion));\n    props.setProperty(\"namespaceID\", String.valueOf(namespaceID));\n    props.setProperty(\"blockpoolID\", blockpoolID);\n    props.setProperty(\"cTime\", String.valueOf(cTime));\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_FILE_VERSION + \" is invalid.\");\n    }\n    \n    if (!blockpoolID.equals(\"\") && !blockpoolID.equals(bpid)) {\n      throw new InconsistentFSStateException(storage,\n          \"Unexpected blockpoolID \" + bpid + \". Expected \" + blockpoolID);\n    }\n    blockpoolID = bpid;\n  }\n  \n  @Override\n  protected void setFieldsFromProperties(Properties props, StorageDirectory sd)\n      throws IOException {\n    setLayoutVersion(props, sd);\n    setNamespaceID(props, sd);\n    setcTime(props, sd);\n    \n    String sbpid = props.getProperty(\"blockpoolID\");","sourceCodeStart":311,"sourceCodeEnd":347,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BlockPoolSliceStorage.java#L311-L347","documentation":"setBlockPoolID found blockpoolID null or empty while reading the block pool's VERSION file — thrown as InconsistentFSStateException('file VERSION is invalid.'). The storage metadata is unusable because the pool identity is missing.","triggerScenarios":"A truncated or empty VERSION file under <data_dir>/current/<bpid>/current/ — crash during a metadata write, disk fault, or manual editing.","commonSituations":"Power loss mid-upgrade; full or failing disk corrupting metadata; operators hand-editing storage files.","solutions":["Inspect <data_dir>/<bpid>/current/VERSION for truncation","Restore it from backup, or reconstruct the blockpoolID line from the BP directory name (bpid == dirname)","If the blocks are re-replicable, delete the BP directory and let the DN re-register and format"],"exampleFix":"# BP-123456/current/VERSION after repair:\n#   namespaceID=123456789\n#   blockpoolID=BP-123456-10.0.0.1-50010   <- was blank\n#   cTime=0\n# layoutVersion=...\nhdfs --daemon restart datanode","handlingStrategy":"validation","validationCode":"Properties p = new Properties();\ntry (FileInputStream in = new FileInputStream(versionFile)) { p.load(in); }\nString bpid = p.getProperty(\"blockpoolID\");\nif (bpid == null || bpid.isEmpty()) {\n  throw new IOException(\"Corrupted VERSION (empty blockpoolID): \" + versionFile);\n}","typeGuard":null,"tryCatchPattern":"catch (InconsistentFSStateException e) {\n  // treat as corrupt storage: quarantine the BP dir, let NN re-replicate\n  quarantineBpDirAndRestart();\n}","preventionTips":["Keep DN storage on reliable local disks, not NAS, to avoid metadata corruption","Back up BP VERSION files before manual storage surgery","Let HDFS re-replicate rather than hand-recovering blocks when feasible"],"tags":["hdfs","datanode","storage","version-file","corruption"],"backgroundTag":"corrupted-version-file","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}