HBASE-10499 In write heavy scenario one of the regions does not get flushed causing RegionTooBusyException (Ram and Ted)

This commit is contained in:
tedyu 2015-01-23 09:43:01 -08:00
parent ab18158e60
commit 74adb11f4c
2 changed files with 14 additions and 6 deletions

View File

@ -619,7 +619,8 @@ class MemStoreFlusher implements FlushRequester {
return this.globalMemStoreLimit;
}
interface FlushQueueEntry extends Delayed {}
interface FlushQueueEntry extends Delayed {
}
/**
* Token to insert into the flush queue that ensures that the flusher does not sleep
@ -639,7 +640,6 @@ class MemStoreFlusher implements FlushRequester {
public boolean equals(Object obj) {
return (this == obj);
}
}
/**
@ -709,8 +709,14 @@ class MemStoreFlusher implements FlushRequester {
@Override
public int compareTo(Delayed other) {
return Long.valueOf(getDelay(TimeUnit.MILLISECONDS) -
// Delay is compared first. If there is a tie, compare region's hash code
int ret = Long.valueOf(getDelay(TimeUnit.MILLISECONDS) -
other.getDelay(TimeUnit.MILLISECONDS)).intValue();
if (ret != 0) {
return ret;
}
FlushQueueEntry otherEntry = (FlushQueueEntry) other;
return hashCode() - otherEntry.hashCode();
}
@Override
@ -720,7 +726,8 @@ class MemStoreFlusher implements FlushRequester {
@Override
public int hashCode() {
return (int) getDelay(TimeUnit.MILLISECONDS);
int hash = (int) getDelay(TimeUnit.MILLISECONDS);
return hash ^ region.hashCode();
}
@Override

View File

@ -34,8 +34,9 @@ public class TestFlushRegionEntry {
@Test
public void test() {
FlushRegionEntry entry = new FlushRegionEntry(Mockito.mock(HRegion.class), true);
FlushRegionEntry other = new FlushRegionEntry(Mockito.mock(HRegion.class), true);
HRegion r = Mockito.mock(HRegion.class);
FlushRegionEntry entry = new FlushRegionEntry(r, true);
FlushRegionEntry other = new FlushRegionEntry(r, true);
assertEquals(entry.hashCode(), other.hashCode());
assertEquals(entry, other);