{"record":{"id":"4a3b38d32085cee3","repo":"apache/hadoop","slug":"version-file-in-current-directory-is-missing","errorCode":null,"errorMessage":"version file in current directory is missing.","messagePattern":"version file in current directory is missing\\.","errorType":"exception","errorClass":"InconsistentFSStateException","httpStatus":null,"severity":"critical","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/common/Storage.java","lineNumber":732,"sourceCode":"\n      // check whether current directory is valid\n      File versionFile = getVersionFile();\n      boolean hasCurrent = versionFile.exists();\n\n      // check which directories exist\n      boolean hasPrevious = getPreviousDir().exists();\n      boolean hasPreviousTmp = getPreviousTmp().exists();\n      boolean hasRemovedTmp = getRemovedTmp().exists();\n      boolean hasFinalizedTmp = getFinalizedTmp().exists();\n      boolean hasCheckpointTmp = getLastCheckpointTmp().exists();\n\n      if (!(hasPreviousTmp || hasRemovedTmp\n          || hasFinalizedTmp || hasCheckpointTmp)) {\n        // no temp dirs - no recovery\n        if (hasCurrent)\n          return StorageState.NORMAL;\n        if (hasPrevious)\n          throw new InconsistentFSStateException(root,\n                              \"version file in current directory is missing.\");\n        if (checkCurrentIsEmpty) {\n          checkEmptyCurrent();\n        }\n        return StorageState.NOT_FORMATTED;\n      }\n\n      if ((hasPreviousTmp?1:0) + (hasRemovedTmp?1:0)\n          + (hasFinalizedTmp?1:0) + (hasCheckpointTmp?1:0) > 1)\n        // more than one temp dirs\n        throw new InconsistentFSStateException(root,\n                                               \"too many temporary directories.\");\n\n      // # of temp dirs == 1 should either recover or complete a transition\n      if (hasCheckpointTmp) {\n        return hasCurrent ? StorageState.COMPLETE_CHECKPOINT\n                          : StorageState.RECOVER_CHECKPOINT;\n      }","sourceCodeStart":714,"sourceCodeEnd":750,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/common/Storage.java#L714-L750","documentation":"In Storage.analyzeStorage, when no transition temp dirs exist and current/VERSION is missing (hasCurrent == false, Storage.java:716-717) but previous/ does exist, the directory is in an impossible state and InconsistentFSStateException('version file in current directory is missing.') aborts startup. previous/ is only supposed to coexist with a complete current/ (the window between upgrade completion and finalize); without current/, the daemon refuses to guess.","triggerScenarios":"NameNode/DataNode/JournalNode startup after an interrupted upgrade/rollback destroyed current/ while previous/ survived, or after VERSION in current/ was deleted/pruned by hand.","commonSituations":"Crash during upgrade finalization or rollback; operators deleting current/ to 'reset' a node while leaving previous/; disk corruption eating current/ but not previous/; partial rsync of a storage dir.","solutions":["Inspect previous/ — it typically holds the last complete pre-upgrade layout: recover by completing the interrupted transition (e.g., restore current/ from a checkpoint/fsimage backup) rather than deleting anything","If the namespace on this directory is disposable, move previous/ aside as a backup and re-format the directory","For a NameNode, prefer restoring from the latest fsimage/checkpoint backup over hand-editing storage state"],"exampleFix":"# diagnosis\nls /dfs/nn/current/VERSION /dfs/nn/previous   # VERSION gone, previous/ present\n\n# recovery options (stop daemons first, back up the whole dir)\nmv /dfs/nn/previous /backup/previous\nsudo -u hdfs hdfs namenode -format            # only if data is disposable","handlingStrategy":"try-catch","validationCode":"// startup preflight for each storage dir\nFile current = new File(sd.getRoot(), Storage.STORAGE_DIR_CURRENT);\nFile previous = new File(sd.getRoot(), Storage.STORAGE_DIR_PREVIOUS);\nboolean hasCurrent = new File(current, \"VERSION\").exists(); // mirrors Storage.java:716-717\nif (!hasCurrent && previous.exists()) {\n  throw new IOException(\"Inconsistent storage: previous/ exists without current/VERSION; \"\n      + \"recover the interrupted transition or move previous/ aside and format\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  daemon.start();\n} catch (InconsistentFSStateException e) {\n  if (e.getMessage().contains(\"version file in current directory is missing\")) {\n    haltWithRunbook(\"Storage dir \" + e.getDir() + \": recover previous/ (crashed upgrade/rollback) \"\n        + \"or back up and reformat; do not delete previous/ blindly\");\n  } else throw e;\n}","preventionTips":["Never manually delete files inside storage directories; let finalize/cleanup commands do it","Finalize completed upgrades promptly so previous/ does not linger across crashes","Keep fsimage backups so current/ can be restored rather than hand-crafted"],"tags":["hdfs","storage","version-file","upgrade","inconsistent-state","namenode-startup"],"backgroundTag":"missing-version-file","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}