HBASE-1058 Prevent runaway compactions; patch 1058-2-v1

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@774017 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andrew Kyle Purtell 2009-05-12 18:54:43 +00:00
parent f9b6ae1af6
commit 816225f395
1 changed files with 10 additions and 16 deletions

View File

@ -223,32 +223,26 @@ class MemcacheFlusher extends Thread implements FlushRequester {
*/ */
private boolean flushRegion(HRegion region, boolean removeFromQueue) { private boolean flushRegion(HRegion region, boolean removeFromQueue) {
// Wait until it is safe to flush. // Wait until it is safe to flush.
// TODO: Fix. This block doesn't work if more than one store. boolean toomany;
int count = 0; do {
boolean triggered = false; toomany = false;
while (count++ < (blockingWaitTime / 500)) {
for (Store hstore: region.stores.values()) { for (Store hstore: region.stores.values()) {
int files = hstore.getStorefilesCount(); int files = hstore.getStorefilesCount();
if (files > this.blockingStoreFilesNumber) { if (files > this.blockingStoreFilesNumber) {
if (!triggered) { if (LOG.isDebugEnabled()) {
server.compactSplitThread.compactionRequested(region, getName()); LOG.debug("Too many store files in store " + hstore + ": " +
LOG.info("Too many store files in store " + hstore + ": " + files + ", waiting");
files + ", pausing");
triggered = true;
} }
toomany = true;
server.compactSplitThread.compactionRequested(region, getName());
try { try {
Thread.sleep(500); Thread.sleep(blockingWaitTime);
} catch (InterruptedException e) { } catch (InterruptedException e) {
// ignore // ignore
} }
continue;
} }
} }
if (triggered) { } while (toomany);
LOG.info("Compaction triggered on region " + region + ", proceeding");
}
break;
}
synchronized (regionsInQueue) { synchronized (regionsInQueue) {
// See comment above for removeFromQueue on why we do not // See comment above for removeFromQueue on why we do not
// take the region out of the set. If removeFromQueue is true, remove it // take the region out of the set. If removeFromQueue is true, remove it