HBASE-13745 Say why a flush was requested in log message
This commit is contained in:
parent
e5df9bb2e2
commit
a6cf9c51d9
|
@ -1942,10 +1942,12 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
|
||||||
/**
|
/**
|
||||||
* Should the memstore be flushed now
|
* Should the memstore be flushed now
|
||||||
*/
|
*/
|
||||||
boolean shouldFlush() {
|
boolean shouldFlush(final StringBuffer whyFlush) {
|
||||||
|
whyFlush.setLength(0);
|
||||||
// This is a rough measure.
|
// This is a rough measure.
|
||||||
if (this.maxFlushedSeqId > 0
|
if (this.maxFlushedSeqId > 0
|
||||||
&& (this.maxFlushedSeqId + this.flushPerChanges < this.sequenceId.get())) {
|
&& (this.maxFlushedSeqId + this.flushPerChanges < this.sequenceId.get())) {
|
||||||
|
whyFlush.append("more than max edits, " + this.flushPerChanges + ", since last flush");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
long modifiedFlushCheckInterval = flushCheckInterval;
|
long modifiedFlushCheckInterval = flushCheckInterval;
|
||||||
|
@ -1966,6 +1968,7 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
|
||||||
for (Store s : getStores()) {
|
for (Store s : getStores()) {
|
||||||
if (s.timeOfOldestEdit() < now - modifiedFlushCheckInterval) {
|
if (s.timeOfOldestEdit() < now - modifiedFlushCheckInterval) {
|
||||||
// we have an old enough edit in the memstore, flush
|
// we have an old enough edit in the memstore, flush
|
||||||
|
whyFlush.append(s.toString() + " has an old edit so flush to free WALs");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1548,15 +1548,17 @@ public class HRegionServer extends HasThread implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void chore() {
|
protected void chore() {
|
||||||
|
final StringBuffer whyFlush = new StringBuffer();
|
||||||
for (Region r : this.server.onlineRegions.values()) {
|
for (Region r : this.server.onlineRegions.values()) {
|
||||||
if (r == null)
|
if (r == null) continue;
|
||||||
continue;
|
if (((HRegion)r).shouldFlush(whyFlush)) {
|
||||||
if (((HRegion)r).shouldFlush()) {
|
|
||||||
FlushRequester requester = server.getFlushRequester();
|
FlushRequester requester = server.getFlushRequester();
|
||||||
if (requester != null) {
|
if (requester != null) {
|
||||||
long randomDelay = RandomUtils.nextInt(RANGE_OF_DELAY) + MIN_DELAY_TIME;
|
long randomDelay = RandomUtils.nextInt(RANGE_OF_DELAY) + MIN_DELAY_TIME;
|
||||||
LOG.info(getName() + " requesting flush for region " +
|
LOG.info(getName() + " requesting flush of " +
|
||||||
r.getRegionInfo().getRegionNameAsString() + " after a delay of " + randomDelay);
|
r.getRegionInfo().getRegionNameAsString() + " because " +
|
||||||
|
whyFlush.toString() +
|
||||||
|
" after random delay " + randomDelay + "ms");
|
||||||
//Throttle the flushes by putting a delay. If we don't throttle, and there
|
//Throttle the flushes by putting a delay. If we don't throttle, and there
|
||||||
//is a balanced write-load on the regions in a table, we might end up
|
//is a balanced write-load on the regions in a table, we might end up
|
||||||
//overwhelming the filesystem with too many flushes at once.
|
//overwhelming the filesystem with too many flushes at once.
|
||||||
|
|
|
@ -927,9 +927,10 @@ public class TestDefaultMemStore extends TestCase {
|
||||||
edge.setCurrentTimeMillis(1234);
|
edge.setCurrentTimeMillis(1234);
|
||||||
s.add(KeyValueTestUtil.create("r", "f", "q", 100, "v"));
|
s.add(KeyValueTestUtil.create("r", "f", "q", 100, "v"));
|
||||||
edge.setCurrentTimeMillis(1234 + 100);
|
edge.setCurrentTimeMillis(1234 + 100);
|
||||||
assertTrue(region.shouldFlush() == false);
|
StringBuffer sb = new StringBuffer();
|
||||||
|
assertTrue(region.shouldFlush(sb) == false);
|
||||||
edge.setCurrentTimeMillis(1234 + 10000);
|
edge.setCurrentTimeMillis(1234 + 10000);
|
||||||
assertTrue(region.shouldFlush() == expected);
|
assertTrue(region.shouldFlush(sb) == expected);
|
||||||
} finally {
|
} finally {
|
||||||
EnvironmentEdgeManager.reset();
|
EnvironmentEdgeManager.reset();
|
||||||
}
|
}
|
||||||
|
@ -960,9 +961,10 @@ public class TestDefaultMemStore extends TestCase {
|
||||||
wFactory.getWAL(hri.getEncodedNameAsBytes()));
|
wFactory.getWAL(hri.getEncodedNameAsBytes()));
|
||||||
HRegion.addRegionToMETA(meta, r);
|
HRegion.addRegionToMETA(meta, r);
|
||||||
edge.setCurrentTimeMillis(1234 + 100);
|
edge.setCurrentTimeMillis(1234 + 100);
|
||||||
assertTrue(meta.shouldFlush() == false);
|
StringBuffer sb = new StringBuffer();
|
||||||
|
assertTrue(meta.shouldFlush(sb) == false);
|
||||||
edge.setCurrentTimeMillis(edge.currentTime() + HRegion.META_CACHE_FLUSH_INTERVAL + 1);
|
edge.setCurrentTimeMillis(edge.currentTime() + HRegion.META_CACHE_FLUSH_INTERVAL + 1);
|
||||||
assertTrue(meta.shouldFlush() == true);
|
assertTrue(meta.shouldFlush(sb) == true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class EnvironmentEdgeForMemstoreTest implements EnvironmentEdge {
|
private class EnvironmentEdgeForMemstoreTest implements EnvironmentEdge {
|
||||||
|
|
Loading…
Reference in New Issue