From 153e0cc37aacf04fec3de51ebc1690e50f16b614 Mon Sep 17 00:00:00 2001 From: Aaron Myers Date: Thu, 16 Feb 2012 22:45:40 +0000 Subject: [PATCH] HDFS-2955. IllegalStateException during standby startup in getCurSegmentTxId. Contributed by Hari Mankude. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/HDFS-1623@1245230 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.HDFS-1623.txt | 2 ++ .../apache/hadoop/hdfs/server/namenode/FSNamesystem.java | 8 ++++++-- .../hadoop/hdfs/server/namenode/ha/TestHASafeMode.java | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.HDFS-1623.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.HDFS-1623.txt index c87faa70d3..4a8b185d9b 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.HDFS-1623.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.HDFS-1623.txt @@ -210,3 +210,5 @@ HDFS-2934. Allow configs to be scoped to all NNs in the nameservice. (todd) HDFS-2935. Shared edits dir property should be suffixed with nameservice and namenodeID (todd) HDFS-2928. ConfiguredFailoverProxyProvider should not create a NameNode proxy with an underlying retry proxy. (Uma Maheswara Rao G via atm) + +HDFS-2955. IllegalStateException during standby startup in getCurSegmentTxId. (Hari Mankude via atm) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java index 128222bce0..8edc4bc88a 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java @@ -3168,8 +3168,12 @@ public long getTransactionsSinceLastCheckpoint() { @Metric({"TransactionsSinceLastLogRoll", "Number of transactions since last edit log roll"}) public long getTransactionsSinceLastLogRoll() { - return (getEditLog().getLastWrittenTxId() - - getEditLog().getCurSegmentTxId()) + 1; + if (isInStandbyState()) { + return 0; + } else { + return getEditLog().getLastWrittenTxId() - + getEditLog().getCurSegmentTxId() + 1; + } } @Metric({"LastWrittenTransactionId", "Transaction ID written to the edit log"}) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestHASafeMode.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestHASafeMode.java index d6babb788a..e07338f8c8 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestHASafeMode.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestHASafeMode.java @@ -116,6 +116,7 @@ private void restartStandby() throws IOException { cluster.restartNameNode(1); nn1 = cluster.getNameNode(1); + assertEquals(nn1.getNamesystem().getTransactionsSinceLastLogRoll(), 0L); } /**