Przeglądaj źródła

HDFS-7302. Remove "downgrade" from "namenode -rollingUpgrade" startup option since it may incorrectly finalize an ongoing rolling upgrade.
Contributed by Kai Sasaki

Tsz-Wo Nicholas Sze 10 lat temu
rodzic
commit
431e7d84c7

+ 4 - 0
hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt

@@ -14,6 +14,10 @@ Trunk (Unreleased)
 
     HDFS-2538. option to disable fsck dots (Mohammad Kamrul Islam via aw)
 
+    HDFS-7302. Remove "downgrade" from "namenode -rollingUpgrade" startup
+    option since it may incorrectly finalize an ongoing rolling upgrade.
+    (Kai Sasaki via szetszwo)
+
   NEW FEATURES
 
     HDFS-3125. Add JournalService to enable Journal Daemon. (suresh)

+ 9 - 1
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/common/HdfsServerConstants.java

@@ -49,7 +49,7 @@ public final class HdfsServerConstants {
 
   /** Startup options for rolling upgrade. */
   public static enum RollingUpgradeStartupOption{
-    ROLLBACK, DOWNGRADE, STARTED;
+    ROLLBACK, STARTED;
 
     public String getOptionString() {
       return StartupOption.ROLLINGUPGRADE.getName() + " "
@@ -64,6 +64,14 @@ public final class HdfsServerConstants {
     private static final RollingUpgradeStartupOption[] VALUES = values();
 
     static RollingUpgradeStartupOption fromString(String s) {
+      if ("downgrade".equalsIgnoreCase(s)) {
+        throw new IllegalArgumentException(
+            "The \"downgrade\" option is no longer supported"
+                + " since it may incorrectly finalize an ongoing rolling upgrade."
+                + " For downgrade instruction, please see the documentation"
+                + " (http://hadoop.apache.org/docs/current/hadoop-project-dist/"
+                + "hadoop-hdfs/HdfsRollingUpgrade.html#Downgrade).");
+      }
       for(RollingUpgradeStartupOption opt : VALUES) {
         if (opt.name().equalsIgnoreCase(s)) {
           return opt;

+ 0 - 3
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogLoader.java

@@ -793,9 +793,6 @@ public class FSEditLogLoader {
             = startOpt.getRollingUpgradeStartupOption(); 
         if (rollingUpgradeOpt == RollingUpgradeStartupOption.ROLLBACK) {
           throw new RollingUpgradeOp.RollbackException();
-        } else if (rollingUpgradeOpt == RollingUpgradeStartupOption.DOWNGRADE) {
-          //ignore upgrade marker
-          break;
         }
       }
       // start rolling upgrade

+ 0 - 4
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImage.java

@@ -687,10 +687,6 @@ public class FSImage implements Closeable {
       long txnsAdvanced = loadEdits(editStreams, target, startOpt, recovery);
       needToSave |= needsResaveBasedOnStaleCheckpoint(imageFile.getFile(),
           txnsAdvanced);
-      if (RollingUpgradeStartupOption.DOWNGRADE.matches(startOpt)) {
-        // rename rollback image if it is downgrade
-        renameCheckpoint(NameNodeFile.IMAGE_ROLLBACK, NameNodeFile.IMAGE);
-      }
     } else {
       // Trigger the rollback for rolling upgrade. Here lastAppliedTxId equals
       // to the last txid in rollback fsimage.

+ 1 - 2
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java

@@ -972,8 +972,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
       MetaRecoveryContext recovery = startOpt.createRecoveryContext();
       final boolean staleImage
           = fsImage.recoverTransitionRead(startOpt, this, recovery);
-      if (RollingUpgradeStartupOption.ROLLBACK.matches(startOpt) ||
-          RollingUpgradeStartupOption.DOWNGRADE.matches(startOpt)) {
+      if (RollingUpgradeStartupOption.ROLLBACK.matches(startOpt)) {
         rollingUpgradeInfo = null;
       }
       final boolean needToSave = staleImage && !haEnabled && !isRollingUpgrade(); 

+ 1 - 1
hadoop-hdfs-project/hadoop-hdfs/src/site/markdown/HDFSCommands.md

@@ -435,7 +435,7 @@ Usage:
 | `-upgrade` `[-clusterid cid]` [`-renameReserved` \<k-v pairs\>] | Namenode should be started with upgrade option after the distribution of new Hadoop version. |
 | `-upgradeOnly` `[-clusterid cid]` [`-renameReserved` \<k-v pairs\>] | Upgrade the specified NameNode and then shutdown it. |
 | `-rollback` | Rollback the NameNode to the previous version. This should be used after stopping the cluster and distributing the old Hadoop version. |
-| `-rollingUpgrade` \<downgrade\|rollback\|started\> | See [Rolling Upgrade document](./HdfsRollingUpgrade.html#NameNode_Startup_Options) for the detail. |
+| `-rollingUpgrade` \<rollback\|started\> | See [Rolling Upgrade document](./HdfsRollingUpgrade.html#NameNode_Startup_Options) for the detail. |
 | `-finalize` | Finalize will remove the previous state of the files system. Recent upgrade will become permanent. Rollback option will not be available anymore. After finalization it shuts the NameNode down. |
 | `-importCheckpoint` | Loads image from a checkpoint directory and save it into the current one. Checkpoint dir is read from property fs.checkpoint.dir |
 | `-initializeSharedEdits` | Format a new shared edits dir and copy in enough edit log segments so that the standby NameNode can start up. |

+ 5 - 6
hadoop-hdfs-project/hadoop-hdfs/src/site/xdoc/HdfsRollingUpgrade.xml

@@ -308,17 +308,13 @@
   <subsection name="NameNode Startup Options" id="dfsadminCommands">
 
   <h4><code>namenode -rollingUpgrade</code></h4>
-  <source>hdfs namenode -rollingUpgrade &lt;downgrade|rollback|started&gt;</source>
+  <source>hdfs namenode -rollingUpgrade &lt;rollback|started&gt;</source>
   <p>
     When a rolling upgrade is in progress,
     the <code>-rollingUpgrade</code> namenode startup option is used to specify
     various rolling upgrade options.
   </p>
     <ul><li>Options:<table>
-      <tr><td><code>downgrade</code></td>
-        <td>Restores the namenode back to the pre-upgrade release
-            and preserves the user data.</td>
-      </tr>
       <tr><td><code>rollback</code></td>
         <td>Restores the namenode back to the pre-upgrade release
             but also reverts the user data back to the pre-upgrade state.</td>
@@ -329,7 +325,10 @@
           with different layout versions during startup.</td>
       </tr>
     </table></li></ul>
-
+  <p>
+    <b>WARN: downgrade options is obsolete.</b>
+      It is not necessary to start namenode with downgrade options explicitly.
+  </p>
   </subsection>
 
   </section>

+ 8 - 4
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestRollingUpgradeDowngrade.java

@@ -36,7 +36,11 @@ import org.junit.Test;
 
 public class TestRollingUpgradeDowngrade {
 
-  @Test(timeout = 300000)
+  /**
+   * Downgrade option is already obsolete. It should throw exception.
+   * @throws Exception
+   */
+  @Test(timeout = 300000, expected = IllegalArgumentException.class)
   public void testDowngrade() throws Exception {
     final Configuration conf = new HdfsConfiguration();
     MiniQJMHACluster cluster = null;
@@ -85,10 +89,10 @@ public class TestRollingUpgradeDowngrade {
   }
 
   /**
-   * Ensure that during downgrade the NN fails to load a fsimage with newer
-   * format.
+   * Ensure that restart namenode with downgrade option should throw exception
+   * because it has been obsolete.
    */
-  @Test(expected = IncorrectVersionException.class)
+  @Test(expected = IllegalArgumentException.class)
   public void testRejectNewFsImage() throws IOException {
     final Configuration conf = new Configuration();
     MiniDFSCluster cluster = null;

+ 0 - 3
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestHdfsServerConstants.java

@@ -83,9 +83,6 @@ public class TestHdfsServerConstants {
     verifyStartupOptionResult("ROLLINGUPGRADE(ROLLBACK)",
                               StartupOption.ROLLINGUPGRADE,
                               RollingUpgradeStartupOption.ROLLBACK);
-    verifyStartupOptionResult("ROLLINGUPGRADE(DOWNGRADE)",
-                              StartupOption.ROLLINGUPGRADE,
-                              RollingUpgradeStartupOption.DOWNGRADE);
     verifyStartupOptionResult("ROLLINGUPGRADE(STARTED)",
         StartupOption.ROLLINGUPGRADE,
         RollingUpgradeStartupOption.STARTED);

+ 0 - 8
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeOptionParsing.java

@@ -120,14 +120,6 @@ public class TestNameNodeOptionParsing {
       assertTrue(RollingUpgradeStartupOption.STARTED.matches(opt));
     }
 
-    {
-      final String[] args = {"-rollingUpgrade", "downgrade"};
-      final StartupOption opt = NameNode.parseArguments(args);
-      assertEquals(StartupOption.ROLLINGUPGRADE, opt);
-      assertEquals(RollingUpgradeStartupOption.DOWNGRADE, opt.getRollingUpgradeStartupOption());
-      assertTrue(RollingUpgradeStartupOption.DOWNGRADE.matches(opt));
-    }
-
     {
       final String[] args = {"-rollingUpgrade", "rollback"};
       final StartupOption opt = NameNode.parseArguments(args);