HBASE-24958 CompactingMemStore.timeOfOldestEdit error update (#2321)
This commit is contained in:
parent
ce59a2ba30
commit
bbfbe33520
|
@ -80,6 +80,7 @@ public abstract class AbstractMemStore implements MemStore {
|
||||||
this.comparator = c;
|
this.comparator = c;
|
||||||
this.regionServices = regionServices;
|
this.regionServices = regionServices;
|
||||||
resetActive();
|
resetActive();
|
||||||
|
resetTimeOfOldestEdit();
|
||||||
this.snapshot = SegmentFactory.instance().createImmutableSegment(c);
|
this.snapshot = SegmentFactory.instance().createImmutableSegment(c);
|
||||||
this.snapshotId = NO_SNAPSHOT_ID;
|
this.snapshotId = NO_SNAPSHOT_ID;
|
||||||
}
|
}
|
||||||
|
@ -95,7 +96,10 @@ public abstract class AbstractMemStore implements MemStore {
|
||||||
memstoreAccounting.getHeapSize(), memstoreAccounting.getOffHeapSize(),
|
memstoreAccounting.getHeapSize(), memstoreAccounting.getOffHeapSize(),
|
||||||
memstoreAccounting.getCellsCount());
|
memstoreAccounting.getCellsCount());
|
||||||
}
|
}
|
||||||
timeOfOldestEdit = Long.MAX_VALUE;
|
}
|
||||||
|
|
||||||
|
protected void resetTimeOfOldestEdit() {
|
||||||
|
this.timeOfOldestEdit = Long.MAX_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -212,6 +212,7 @@ public class CompactingMemStore extends AbstractMemStore {
|
||||||
// region level lock ensures pushing active to pipeline is done in isolation
|
// region level lock ensures pushing active to pipeline is done in isolation
|
||||||
// no concurrent update operations trying to flush the active segment
|
// no concurrent update operations trying to flush the active segment
|
||||||
pushActiveToPipeline(getActive());
|
pushActiveToPipeline(getActive());
|
||||||
|
resetTimeOfOldestEdit();
|
||||||
snapshotId = EnvironmentEdgeManager.currentTime();
|
snapshotId = EnvironmentEdgeManager.currentTime();
|
||||||
// in both cases whatever is pushed to snapshot is cleared from the pipeline
|
// in both cases whatever is pushed to snapshot is cleared from the pipeline
|
||||||
if (compositeSnapshot) {
|
if (compositeSnapshot) {
|
||||||
|
|
|
@ -109,6 +109,7 @@ public class DefaultMemStore extends AbstractMemStore {
|
||||||
}
|
}
|
||||||
this.snapshot = immutableSegment;
|
this.snapshot = immutableSegment;
|
||||||
resetActive();
|
resetActive();
|
||||||
|
resetTimeOfOldestEdit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new MemStoreSnapshot(this.snapshotId, this.snapshot);
|
return new MemStoreSnapshot(this.snapshotId, this.snapshot);
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
package org.apache.hadoop.hbase.regionserver;
|
package org.apache.hadoop.hbase.regionserver;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertNotEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
@ -131,6 +132,29 @@ public class TestCompactingMemStore extends TestDefaultMemStore {
|
||||||
assertNotNull(chunkCreator);
|
assertNotNull(chunkCreator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A simple test which flush in memory affect timeOfOldestEdit
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testTimeOfOldestEdit() {
|
||||||
|
assertEquals(Long.MAX_VALUE, memstore.timeOfOldestEdit());
|
||||||
|
final byte[] r = Bytes.toBytes("r");
|
||||||
|
final byte[] f = Bytes.toBytes("f");
|
||||||
|
final byte[] q = Bytes.toBytes("q");
|
||||||
|
final byte[] v = Bytes.toBytes("v");
|
||||||
|
final KeyValue kv = new KeyValue(r, f, q, v);
|
||||||
|
memstore.add(kv, null);
|
||||||
|
long timeOfOldestEdit = memstore.timeOfOldestEdit();
|
||||||
|
assertNotEquals(Long.MAX_VALUE, timeOfOldestEdit);
|
||||||
|
|
||||||
|
((CompactingMemStore)memstore).flushInMemory();
|
||||||
|
assertEquals(timeOfOldestEdit, memstore.timeOfOldestEdit());
|
||||||
|
memstore.add(kv, null);
|
||||||
|
assertEquals(timeOfOldestEdit, memstore.timeOfOldestEdit());
|
||||||
|
memstore.snapshot();
|
||||||
|
assertEquals(Long.MAX_VALUE, memstore.timeOfOldestEdit());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A simple test which verifies the 3 possible states when scanning across snapshot.
|
* A simple test which verifies the 3 possible states when scanning across snapshot.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue