{"record":{"id":"47bf6e96067d6d85","repo":"apache/hadoop","slug":"cannot-rollback-none-of-the-storage-directories-c","errorCode":null,"errorMessage":"Cannot rollback. None of the storage directories contain previous fs state.","messagePattern":"Cannot rollback\\. None of the storage directories contain previous fs state\\.","errorType":"exception","errorClass":"java.io.IOException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImage.java","lineNumber":550,"sourceCode":"          continue;\n        }\n        LOG.info(\"Can perform rollback for \" + sd);\n        canRollback = true;\n      }\n      \n      if (fsns.isHaEnabled()) {\n        // If HA is enabled, check if the shared log can be rolled back as well.\n        editLog.initJournalsForWrite();\n        boolean canRollBackSharedEditLog = editLog.canRollBackSharedLog(\n            prevState.getStorage(), storage.getServiceLayoutVersion());\n        if (canRollBackSharedEditLog) {\n          LOG.info(\"Can perform rollback for shared edit log.\");\n          canRollback = true;\n        }\n      }\n      \n      if (!canRollback)\n        throw new IOException(\"Cannot rollback. None of the storage \"\n            + \"directories contain previous fs state.\");\n  \n      // Now that we know all directories are going to be consistent\n      // Do rollback for each directory containing previous state\n      for (Iterator<StorageDirectory> it = storage.dirIterator(false); it.hasNext();) {\n        StorageDirectory sd = it.next();\n        LOG.info(\"Rolling back storage directory \" + sd.getRoot()\n                 + \".\\n   new LV = \" + prevState.getStorage().getLayoutVersion()\n                 + \"; new CTime = \" + prevState.getStorage().getCTime());\n        NNUpgradeUtil.doRollBack(sd);\n      }\n      if (fsns.isHaEnabled()) {\n        // If HA is enabled, try to roll back the shared log as well.\n        editLog.doRollback();\n      }\n      \n      isUpgradeFinalized = true;\n    } finally {","sourceCodeStart":532,"sourceCodeEnd":568,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImage.java#L532-L568","documentation":"doRollback() requires a previous/ snapshot in at least one local storage directory — or, in HA, a shared edits dir that can roll back. Finding none means there is nothing to revert to: typically the upgrade was already finalized (finalize removes previous/) or this namespace never upgraded, so -rollback aborts.","triggerScenarios":"Running 'hdfs namenode -rollback' after 'hdfs dfsadmin -finalizeUpgrade' removed previous/; rolling back a freshly formatted namespace; previous/ present on a volume that is not mounted so it is invisible.","commonSituations":"Operator decides to roll back after finalize already ran; confusion between rollback (needs previous/) and downgrade (needs old binaries); mount lost on the disk holding previous/.","solutions":["Verify whether previous/ exists: ls <each dfs.namenode.name.dir>/previous.","If it exists on an unmounted disk, fix mounts and retry.","If the upgrade was already finalized, rollback is impossible: stay on the current version, downgrade binaries if the layout still matches, or restore metadata from backup.","In HA, also verify the shared edits dir (JournalNodes) can roll back."],"exampleFix":"# before\nhdfs namenode -rollback\n# IOException: Cannot rollback. None of the storage directories contain previous fs state.\n\n# after: confirm state, then choose another path\nls /dfs/nn/current /dfs/nn/previous 2>&1   # previous/ absent => already finalized\nhdfs dfsadmin -fs nn:8020 -report           # proceed on current version, or restore backup","handlingStrategy":"validation","validationCode":"boolean anyPrevious = nameDirs.stream()\n    .anyMatch(u -> Files.exists(Paths.get(u.getPath(), \"previous\")));\nif (!anyPrevious) {\n  throw new IllegalStateException(\n      \"Nothing to roll back to: no previous/ in any name dir\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do not finalize until the new version is proven good — finalize destroys previous/.","During upgrade windows, verify previous/ exists before planning a rollback.","Back up metadata before finalize."],"tags":["hdfs","namenode","rollback","upgrade"],"backgroundTag":"rollback-not-possible","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}