diff --git a/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java b/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java index 623edbe..ef13043 100644 --- a/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java +++ b/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java @@ -1353,17 +1353,23 @@ public class HLog implements Syncable { } // sync txn to file system this.sync(); - } finally { // updateLock not needed for removing snapshot's entry // Cleaning up of lastSeqWritten is in the finally clause because we // don't want to confuse getOldestOutstandingSeqNum() this.lastSeqWritten.remove(getSnapshotName(encodedRegionName)); - Long l = this.lastSeqWritten.remove(encodedRegionName); - if (l != null) { - LOG.warn("Why is there a raw encodedRegionName in lastSeqWritten? name=" + - Bytes.toString(encodedRegionName) + ", seqid=" + l); - } + + // So, we don't want to remove our region from lastSeqWritten if we are + // just flushing but we do want to remove ourselves if flushing on close + // (on close, the final flush will happen with updates blocked). To tell + // between the two cases, compare seqids. We can remove ourselves if the + // id passed in here is same as when flush started -- no new edits have + // come in on this region; either no new edits came in or the update + // lock is up because we are closing so safe to remove ourselves. + Long seq = this.lastSeqWritten.get(encodedRegionName); + if (seq != null && logSeqId >= seq.longValue()) { + this.lastSeqWritten.remove(encodedRegionName); + } this.cacheFlushLock.unlock(); } }