diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLog.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLog.java index c9ee32b39bb..8454a46eeb8 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLog.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLog.java @@ -596,7 +596,15 @@ public class FSEditLog implements LogsPurgeable { */ void logSyncAll() { // Make sure we're synced up to the most recent transaction ID. - logSync(getLastWrittenTxId()); + long lastWrittenTxId = getLastWrittenTxId(); + LOG.info("logSyncAll toSyncToTxId=" + lastWrittenTxId + + " lastSyncedTxid=" + synctxid + + " mostRecentTxid=" + txid); + logSync(lastWrittenTxId); + lastWrittenTxId = getLastWrittenTxId(); + LOG.info("Done logSyncAll lastWrittenTxId=" + lastWrittenTxId + + " lastSyncedTxid=" + synctxid + + " mostRecentTxid=" + txid); } /** @@ -1358,7 +1366,8 @@ public class FSEditLog implements LogsPurgeable { * Transitions from IN_SEGMENT state to BETWEEN_LOG_SEGMENTS state. */ public synchronized void endCurrentLogSegment(boolean writeEndTxn) { - LOG.info("Ending log segment " + curSegmentTxId); + LOG.info("Ending log segment " + curSegmentTxId + + ", " + getLastWrittenTxId()); Preconditions.checkState(isSegmentOpen(), "Bad state: %s", state); @@ -1372,7 +1381,10 @@ public class FSEditLog implements LogsPurgeable { printStatistics(true); final long lastTxId = getLastWrittenTxId(); - + final long lastSyncedTxId = getSyncTxId(); + Preconditions.checkArgument(lastTxId == lastSyncedTxId, + "LastWrittenTxId %s is expected to be the same as lastSyncedTxId %s", + lastTxId, lastSyncedTxId); try { journalSet.finalizeLogSegment(curSegmentTxId, lastTxId); editLogStream = null;