From 942c54cf565894e55c33f615f20db571754948fa Mon Sep 17 00:00:00 2001 From: Michael Stack Date: Tue, 5 Aug 2008 19:05:48 +0000 Subject: [PATCH] HBASE-790 During import, single region blocks requests for >10 minutes, thread dumps, throws out pending requests, and continues git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@682874 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 3 ++ .../hadoop/hbase/regionserver/Flusher.java | 1 - .../hadoop/hbase/regionserver/HRegion.java | 32 +++++++++++-------- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index f0a611ed070..25e94b709a7 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -224,6 +224,9 @@ Release 0.2.0 HBASE-751 dfs exception and regionserver stuck during heavy write load HBASE-793 HTable.getStartKeys() ignores table names when matching columns (Andrew Purtell and Dru Jensen via Stack) + HBASE-790 During import, single region blocks requests for >10 minutes, + thread dumps, throws out pending requests, and continues + (Jonathan Gray via Stack) IMPROVEMENTS HBASE-559 MR example job to count table rows diff --git a/src/java/org/apache/hadoop/hbase/regionserver/Flusher.java b/src/java/org/apache/hadoop/hbase/regionserver/Flusher.java index 8d6895b936d..6d30d5f4f07 100644 --- a/src/java/org/apache/hadoop/hbase/regionserver/Flusher.java +++ b/src/java/org/apache/hadoop/hbase/regionserver/Flusher.java @@ -237,7 +237,6 @@ class Flusher extends Thread implements FlushRequester { if (!regionsInQueue.contains(r)) { regionsInQueue.add(r); flushQueue.add(r); - r.setLastFlushTime(now); } } } diff --git a/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java b/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java index a713d1015a0..875eb7dfbec 100644 --- a/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java +++ b/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java @@ -317,7 +317,6 @@ public class HRegion implements HConstants { 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 @@ public class HRegion implements HConstants { 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 @@ public class HRegion implements HConstants { boolean isReadOnly() { return this.readOnly; } + + boolean isFlushRequested() { + return this.flushRequested; + } } private volatile WriteState writestate = new WriteState(); @@ -689,11 +694,6 @@ public class HRegion implements HConstants { return this.lastFlushTime; } - /** @param t the lastFlushTime */ - void setLastFlushTime(long t) { - this.lastFlushTime = t; - } - ////////////////////////////////////////////////////////////////////////////// // HRegion maintenance. // @@ -946,7 +946,7 @@ public class HRegion implements HConstants { } 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 @@ public class HRegion implements HConstants { } finally { synchronized (writestate) { writestate.flushing = false; + this.writestate.flushRequested = false; writestate.notifyAll(); } } @@ -1008,7 +1009,6 @@ public class HRegion implements HConstants { 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 @@ public class HRegion implements HConstants { releaseRowLock(lid); } } - + /* * Check if resources to support an update. * @@ -1605,8 +1605,7 @@ public class HRegion implements HConstants { 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 @@ public class HRegion implements HConstants { } 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); }