HDFS-5874. Should not compare DataNode current layout version with that of NameNode in DataStrorage.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/HDFS-5535@1565750 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brandon Li 2014-02-07 18:25:41 +00:00
parent ccf08d9dc8
commit 300e4906af
3 changed files with 22 additions and 35 deletions

View File

@ -25,3 +25,6 @@ HDFS-5535 subtasks:
HDFS-5869. When starting rolling upgrade or NN restarts, NN should create HDFS-5869. When starting rolling upgrade or NN restarts, NN should create
a checkpoint right before the upgrade marker. (szetszwo) a checkpoint right before the upgrade marker. (szetszwo)
HDFS-5874. Should not compare DataNode current layout version with that of
NameNode in DataStrorage. (brandonli)

View File

@ -201,12 +201,6 @@ private void checkNNVersion(NamespaceInfo nsInfo)
"DataNode version '" + dnVersion + "' but is within acceptable " + "DataNode version '" + dnVersion + "' but is within acceptable " +
"limits. Note: This is normal during a rolling upgrade."); "limits. Note: This is normal during a rolling upgrade.");
} }
if (HdfsConstants.DATANODE_LAYOUT_VERSION != nsInfo.getLayoutVersion()) {
LOG.info("DataNode and NameNode layout versions are different:" +
" DataNode version: "+ HdfsConstants.DATANODE_LAYOUT_VERSION +
" NameNode version: "+ nsInfo.getLayoutVersion());
}
} }
private void connectToNNAndHandshake() throws IOException { private void connectToNNAndHandshake() throws IOException {

View File

@ -130,9 +130,8 @@ synchronized void recoverTransitionRead(DataNode datanode,
// DN storage has been initialized, no need to do anything // DN storage has been initialized, no need to do anything
return; return;
} }
if( HdfsConstants.DATANODE_LAYOUT_VERSION == nsInfo.getLayoutVersion()) LOG.info("Data-node version: " + HdfsConstants.DATANODE_LAYOUT_VERSION
LOG.info("Data-node version: " + HdfsConstants.DATANODE_LAYOUT_VERSION + + " and name-node layout version: " + nsInfo.getLayoutVersion());
" and name-node layout version: " + nsInfo.getLayoutVersion());
// 1. For each data directory calculate its state and // 1. For each data directory calculate its state and
// check whether all is consistent before transitioning. // check whether all is consistent before transitioning.
@ -184,8 +183,6 @@ synchronized void recoverTransitionRead(DataNode datanode,
// while others could be uptodate for the regular startup. // while others could be uptodate for the regular startup.
for(int idx = 0; idx < getNumStorageDirs(); idx++) { for(int idx = 0; idx < getNumStorageDirs(); idx++) {
doTransition(datanode, getStorageDir(idx), nsInfo, startOpt); doTransition(datanode, getStorageDir(idx), nsInfo, startOpt);
assert this.getLayoutVersion() == nsInfo.getLayoutVersion() :
"Data-node and name-node layout versions must be the same.";
createStorageID(getStorageDir(idx)); createStorageID(getStorageDir(idx));
} }
@ -450,15 +447,13 @@ private void doTransition( DataNode datanode,
return; return;
} }
// layoutVersion < LAYOUT_VERSION. I.e. stored layout version is newer // layoutVersion < DATANODE_LAYOUT_VERSION. I.e. stored layout version is newer
// than the version supported by datanode. This should have been caught // than the version supported by datanode. This should have been caught
// in readProperties(), even if rollback was not carried out or somehow // in readProperties(), even if rollback was not carried out or somehow
// failed. // failed.
throw new IOException("BUG: The stored LV = " + this.getLayoutVersion() throw new IOException("BUG: The stored LV = " + this.getLayoutVersion()
+ " is newer than the supported LV = " + " is newer than the supported LV = "
+ HdfsConstants.DATANODE_LAYOUT_VERSION + HdfsConstants.DATANODE_LAYOUT_VERSION);
+ " or name node LV = "
+ nsInfo.getLayoutVersion());
} }
/** /**
@ -491,8 +486,9 @@ void doUpgrade(StorageDirectory sd, NamespaceInfo nsInfo) throws IOException {
// The VERSION file is already read in. Override the layoutVersion // The VERSION file is already read in. Override the layoutVersion
// field and overwrite the file. // field and overwrite the file.
LOG.info("Updating layout version from " + layoutVersion + " to " LOG.info("Updating layout version from " + layoutVersion + " to "
+ nsInfo.getLayoutVersion() + " for storage " + sd.getRoot()); + HdfsConstants.DATANODE_LAYOUT_VERSION + " for storage "
layoutVersion = nsInfo.getLayoutVersion(); + sd.getRoot());
layoutVersion = HdfsConstants.DATANODE_LAYOUT_VERSION;
writeProperties(sd); writeProperties(sd);
return; return;
} }
@ -500,7 +496,7 @@ void doUpgrade(StorageDirectory sd, NamespaceInfo nsInfo) throws IOException {
LOG.info("Upgrading storage directory " + sd.getRoot() LOG.info("Upgrading storage directory " + sd.getRoot()
+ ".\n old LV = " + this.getLayoutVersion() + ".\n old LV = " + this.getLayoutVersion()
+ "; old CTime = " + this.getCTime() + "; old CTime = " + this.getCTime()
+ ".\n new LV = " + nsInfo.getLayoutVersion() + ".\n new LV = " + HdfsConstants.DATANODE_LAYOUT_VERSION
+ "; new CTime = " + nsInfo.getCTime()); + "; new CTime = " + nsInfo.getCTime());
File curDir = sd.getCurrentDir(); File curDir = sd.getCurrentDir();
@ -587,20 +583,13 @@ void doRollback( StorageDirectory sd,
File prevDir = sd.getPreviousDir(); File prevDir = sd.getPreviousDir();
// This is a regular startup or a post-federation rollback // This is a regular startup or a post-federation rollback
if (!prevDir.exists()) { if (!prevDir.exists()) {
// The current datanode version supports federation and the layout if (DataNodeLayoutVersion.supports(LayoutVersion.Feature.FEDERATION,
// version from namenode matches what the datanode supports. An invalid HdfsConstants.DATANODE_LAYOUT_VERSION)) {
// rollback may happen if namenode didn't rollback and datanode is readProperties(sd, HdfsConstants.DATANODE_LAYOUT_VERSION);
// running a wrong version. But this will be detected in block pool
// level and the invalid VERSION content will be overwritten when
// the error is corrected and rollback is retried.
if (DataNodeLayoutVersion.supports(
LayoutVersion.Feature.FEDERATION,
HdfsConstants.DATANODE_LAYOUT_VERSION) &&
HdfsConstants.DATANODE_LAYOUT_VERSION == nsInfo.getLayoutVersion()) {
readProperties(sd, nsInfo.getLayoutVersion());
writeProperties(sd); writeProperties(sd);
LOG.info("Layout version rolled back to " + LOG.info("Layout version rolled back to "
nsInfo.getLayoutVersion() + " for storage " + sd.getRoot()); + HdfsConstants.DATANODE_LAYOUT_VERSION + " for storage "
+ sd.getRoot());
} }
return; return;
} }
@ -615,10 +604,11 @@ void doRollback( StorageDirectory sd,
"Cannot rollback to a newer state.\nDatanode previous state: LV = " "Cannot rollback to a newer state.\nDatanode previous state: LV = "
+ prevInfo.getLayoutVersion() + " CTime = " + prevInfo.getCTime() + prevInfo.getLayoutVersion() + " CTime = " + prevInfo.getCTime()
+ " is newer than the namespace state: LV = " + " is newer than the namespace state: LV = "
+ nsInfo.getLayoutVersion() + " CTime = " + nsInfo.getCTime()); + HdfsConstants.DATANODE_LAYOUT_VERSION + " CTime = "
+ nsInfo.getCTime());
LOG.info("Rolling back storage directory " + sd.getRoot() LOG.info("Rolling back storage directory " + sd.getRoot()
+ ".\n target LV = " + nsInfo.getLayoutVersion() + ".\n target LV = " + HdfsConstants.DATANODE_LAYOUT_VERSION
+ "; target CTime = " + nsInfo.getCTime()); + "; target CTime = " + nsInfo.getCTime());
File tmpDir = sd.getRemovedTmp(); File tmpDir = sd.getRemovedTmp();
assert !tmpDir.exists() : "removed.tmp directory must not exist."; assert !tmpDir.exists() : "removed.tmp directory must not exist.";
// rename current to tmp // rename current to tmp