apache/hadoop · error · java.io.IOException
Cannot rollback. None of the storage directories contain pre
Error message
Cannot rollback. None of the storage directories contain previous fs state.
What it means
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.
Source
Thrown at hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImage.java:550
continue;
}
LOG.info("Can perform rollback for " + sd);
canRollback = true;
}
if (fsns.isHaEnabled()) {
// If HA is enabled, check if the shared log can be rolled back as well.
editLog.initJournalsForWrite();
boolean canRollBackSharedEditLog = editLog.canRollBackSharedLog(
prevState.getStorage(), storage.getServiceLayoutVersion());
if (canRollBackSharedEditLog) {
LOG.info("Can perform rollback for shared edit log.");
canRollback = true;
}
}
if (!canRollback)
throw new IOException("Cannot rollback. None of the storage "
+ "directories contain previous fs state.");
// Now that we know all directories are going to be consistent
// Do rollback for each directory containing previous state
for (Iterator<StorageDirectory> it = storage.dirIterator(false); it.hasNext();) {
StorageDirectory sd = it.next();
LOG.info("Rolling back storage directory " + sd.getRoot()
+ ".\n new LV = " + prevState.getStorage().getLayoutVersion()
+ "; new CTime = " + prevState.getStorage().getCTime());
NNUpgradeUtil.doRollBack(sd);
}
if (fsns.isHaEnabled()) {
// If HA is enabled, try to roll back the shared log as well.
editLog.doRollback();
}
isUpgradeFinalized = true;
} finally {View on GitHub (pinned to 2add963021)
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.
Example fix
# before hdfs namenode -rollback # IOException: Cannot rollback. None of the storage directories contain previous fs state. # after: confirm state, then choose another path ls /dfs/nn/current /dfs/nn/previous 2>&1 # previous/ absent => already finalized hdfs dfsadmin -fs nn:8020 -report # proceed on current version, or restore backup
Defensive patterns
Strategy: validation
Validate before calling
boolean anyPrevious = nameDirs.stream()
.anyMatch(u -> Files.exists(Paths.get(u.getPath(), "previous")));
if (!anyPrevious) {
throw new IllegalStateException(
"Nothing to roll back to: no previous/ in any name dir");
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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/.
Related errors
- Directory {dir} is in an inconsistent state: previous fs sta
- Cannot rollback to storage version {prevStorage.getLayoutVer
- too many temporary directories.
- *********** Upgrade is not supported from this older versio
- Cannot rollback to a newer state. Datanode previous state: L
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/47bf6e96067d6d85.
Report an issue: GitHub.