HBASE-12478 HBASE-10141 and MIN_VERSIONS are not compatible
This commit is contained in:
parent
97b38fbdb4
commit
9583d14747
|
@ -1517,6 +1517,11 @@ public class HStore implements Store {
|
|||
|
||||
private void removeUnneededFiles() throws IOException {
|
||||
if (!conf.getBoolean("hbase.store.delete.expired.storefile", true)) return;
|
||||
if (getFamily().getMinVersions() > 0) {
|
||||
LOG.debug("Skipping expired store file removal due to min version being " +
|
||||
getFamily().getMinVersions());
|
||||
return;
|
||||
}
|
||||
this.lock.readLock().lock();
|
||||
Collection<StoreFile> delSfs = null;
|
||||
try {
|
||||
|
|
|
@ -280,6 +280,14 @@ public class TestStore {
|
|||
|
||||
@Test
|
||||
public void testDeleteExpiredStoreFiles() throws Exception {
|
||||
testDeleteExpiredStoreFiles(0);
|
||||
testDeleteExpiredStoreFiles(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* @param minVersions the MIN_VERSIONS for the column family
|
||||
*/
|
||||
public void testDeleteExpiredStoreFiles(int minVersions) throws Exception {
|
||||
int storeFileNum = 4;
|
||||
int ttl = 4;
|
||||
IncrementingEnvironmentEdge edge = new IncrementingEnvironmentEdge();
|
||||
|
@ -292,6 +300,7 @@ public class TestStore {
|
|||
conf.setInt(CompactionConfiguration.HBASE_HSTORE_COMPACTION_MIN_KEY, 5);
|
||||
|
||||
HColumnDescriptor hcd = new HColumnDescriptor(family);
|
||||
hcd.setMinVersions(minVersions);
|
||||
hcd.setTimeToLive(ttl);
|
||||
init(name.getMethodName(), conf, hcd);
|
||||
|
||||
|
@ -320,10 +329,14 @@ public class TestStore {
|
|||
assertNull(this.store.requestCompaction());
|
||||
Collection<StoreFile> sfs = this.store.getStorefiles();
|
||||
// Ensure i files are gone.
|
||||
assertEquals(storeFileNum - i, sfs.size());
|
||||
// Ensure only non-expired files remain.
|
||||
for (StoreFile sf : sfs) {
|
||||
assertTrue(sf.getReader().getMaxTimestamp() >= (edge.currentTime() - storeTtl));
|
||||
if (minVersions == 0) {
|
||||
assertEquals(storeFileNum - i, sfs.size());
|
||||
// Ensure only non-expired files remain.
|
||||
for (StoreFile sf : sfs) {
|
||||
assertTrue(sf.getReader().getMaxTimestamp() >= (edge.currentTime() - storeTtl));
|
||||
}
|
||||
} else {
|
||||
assertEquals(storeFileNum, sfs.size());
|
||||
}
|
||||
// Let the next store file expired.
|
||||
edge.incrementTime(sleepTime);
|
||||
|
@ -331,7 +344,9 @@ public class TestStore {
|
|||
assertNull(this.store.requestCompaction());
|
||||
Collection<StoreFile> sfs = this.store.getStorefiles();
|
||||
// Assert the last expired file is not removed.
|
||||
assertEquals(1, sfs.size());
|
||||
if (minVersions == 0) {
|
||||
assertEquals(1, sfs.size());
|
||||
}
|
||||
long ts = sfs.iterator().next().getReader().getMaxTimestamp();
|
||||
assertTrue(ts < (edge.currentTime() - storeTtl));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue