Index: src/java/org/apache/hadoop/hbase/regionserver/Flusher.java =================================================================== --- src/java/org/apache/hadoop/hbase/regionserver/Flusher.java (revision 681822) +++ src/java/org/apache/hadoop/hbase/regionserver/Flusher.java (working copy) @@ -237,7 +237,6 @@ if (!regionsInQueue.contains(r)) { regionsInQueue.add(r); flushQueue.add(r); - r.setLastFlushTime(now); } } } Index: src/java/org/apache/hadoop/hbase/regionserver/HRegion.java =================================================================== --- src/java/org/apache/hadoop/hbase/regionserver/HRegion.java (revision 681895) +++ src/java/org/apache/hadoop/hbase/regionserver/HRegion.java (working copy) @@ -317,7 +317,6 @@ new ConcurrentHashMap(); private final Map> targetColumns = new ConcurrentHashMap>(); - private volatile boolean flushRequested = false; // Default access because read by tests. final Map stores = new ConcurrentHashMap(); final AtomicLong memcacheSize = new AtomicLong(0); @@ -337,6 +336,8 @@ static class WriteState { // Set while a memcache flush is happening. volatile boolean flushing = false; + // Set when a flush has been requested. + volatile boolean flushRequested = false; // Set while a compaction is running. volatile boolean compacting = false; // Gets set in close. If set, cannot compact or flush again. @@ -355,6 +356,10 @@ boolean isReadOnly() { return this.readOnly; } + + boolean isFlushRequested() { + return this.flushRequested; + } } private volatile WriteState writestate = new WriteState(); @@ -689,11 +694,6 @@ return this.lastFlushTime; } - /** @param t the lastFlushTime */ - void setLastFlushTime(long t) { - this.lastFlushTime = t; - } - ////////////////////////////////////////////////////////////////////////////// // HRegion maintenance. // @@ -946,7 +946,7 @@ } synchronized (writestate) { if (!writestate.flushing && writestate.writesEnabled) { - writestate.flushing = true; + this.writestate.flushing = true; } else { if(LOG.isDebugEnabled()) { LOG.debug("NOT flushing memcache for region " + this + @@ -968,6 +968,7 @@ } finally { synchronized (writestate) { writestate.flushing = false; + this.writestate.flushRequested = false; writestate.notifyAll(); } } @@ -1008,7 +1009,6 @@ private boolean internalFlushcache() throws IOException { final long startTime = System.currentTimeMillis(); // Clear flush flag. - this.flushRequested = false; // Record latest flush time this.lastFlushTime = startTime; // If nothing to flush, return and avoid logging start/stop flush. @@ -1411,7 +1411,7 @@ releaseRowLock(lid); } } - + /* * Check if resources to support an update. * @@ -1605,8 +1605,7 @@ size = this.memcacheSize.addAndGet( getStore(key.getColumn()).add(key, e.getValue())); } - flush = this.flushListener != null && !this.flushRequested && - isFlushSize(size); + flush = isFlushSize(size); } finally { this.updatesLock.readLock().unlock(); } @@ -1617,11 +1616,16 @@ } private void requestFlush() { - if (this.flushListener == null || this.flushRequested) { + if (this.flushListener == null) { return; } - this.flushListener.request(this); - this.flushRequested = true; + synchronized (writestate) { + if (this.writestate.isFlushRequested()) { + return; + } + writestate.flushRequested = true; + this.flushListener.request(this); + } if (LOG.isDebugEnabled()) { LOG.debug("Flush requested on " + this); }