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