HBASE-19339 Eager policy results in the negative size of memstore

This commit is contained in:
Chia-Ping Tsai 2017-12-01 16:09:59 +08:00
parent bc321a3bdd
commit be4f158afd
6 changed files with 19 additions and 25 deletions

View File

@ -2451,13 +2451,10 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
} }
for (HStore s : storesToFlush) { for (HStore s : storesToFlush) {
MemStoreSize flushableSize = s.getFlushableSize();
totalSizeOfFlushableStores.incMemStoreSize(flushableSize);
storeFlushCtxs.put(s.getColumnFamilyDescriptor().getName(), storeFlushCtxs.put(s.getColumnFamilyDescriptor().getName(),
s.createFlushContext(flushOpSeqId, tracker)); s.createFlushContext(flushOpSeqId, tracker));
// for writing stores to WAL // for writing stores to WAL
committedFiles.put(s.getColumnFamilyDescriptor().getName(), null); committedFiles.put(s.getColumnFamilyDescriptor().getName(), null);
storeFlushableSize.put(s.getColumnFamilyDescriptor().getName(), flushableSize);
} }
// write the snapshot start to WAL // write the snapshot start to WAL
@ -2470,9 +2467,11 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
} }
// Prepare flush (take a snapshot) // Prepare flush (take a snapshot)
for (StoreFlushContext flush : storeFlushCtxs.values()) { storeFlushCtxs.forEach((name, flush) -> {
flush.prepare(); MemStoreSize snapshotSize = flush.prepare();
} totalSizeOfFlushableStores.incMemStoreSize(snapshotSize);
storeFlushableSize.put(name, snapshotSize);
});
} catch (IOException ex) { } catch (IOException ex) {
doAbortFlushToWAL(wal, flushOpSeqId, committedFiles); doAbortFlushToWAL(wal, flushOpSeqId, committedFiles);
throw ex; throw ex;

View File

@ -48,7 +48,6 @@ import java.util.function.Predicate;
import java.util.function.ToLongFunction; import java.util.function.ToLongFunction;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.LongStream; import java.util.stream.LongStream;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
@ -2185,12 +2184,13 @@ public class HStore implements Store, HeapSize, StoreConfigInformation, Propagat
* If necessary, the lock can be added with the patch provided in HBASE-10087 * If necessary, the lock can be added with the patch provided in HBASE-10087
*/ */
@Override @Override
public void prepare() { public MemStoreSize prepare() {
// passing the current sequence number of the wal - to allow bookkeeping in the memstore // passing the current sequence number of the wal - to allow bookkeeping in the memstore
this.snapshot = memstore.snapshot(); this.snapshot = memstore.snapshot();
this.cacheFlushCount = snapshot.getCellsCount(); this.cacheFlushCount = snapshot.getCellsCount();
this.cacheFlushSize = snapshot.getDataSize(); this.cacheFlushSize = snapshot.getDataSize();
committedFiles = new ArrayList<>(1); committedFiles = new ArrayList<>(1);
return new MemStoreSize(snapshot.getDataSize(), snapshot.getHeapSize());
} }
@Override @Override

View File

@ -20,10 +20,9 @@ package org.apache.hadoop.hbase.regionserver;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.Path;
import org.apache.yetus.audience.InterfaceAudience;
import org.apache.hadoop.hbase.monitoring.MonitoredTask; import org.apache.hadoop.hbase.monitoring.MonitoredTask;
import org.apache.yetus.audience.InterfaceAudience;
/** /**
* A package protected interface for a store flushing. * A package protected interface for a store flushing.
@ -34,12 +33,11 @@ interface StoreFlushContext {
/** /**
* Prepare for a store flush (create snapshot) * Prepare for a store flush (create snapshot)
*
* Requires pausing writes. * Requires pausing writes.
*
* A very short operation. * A very short operation.
* @return The size of snapshot to flush
*/ */
void prepare(); MemStoreSize prepare();
/** /**
* Flush the cache (create the new store file) * Flush the cache (create the new store file)

View File

@ -18,14 +18,10 @@
*/ */
package org.apache.hadoop.hbase; package org.apache.hadoop.hbase;
import org.apache.hadoop.hbase.testclassification.FlakeyTests;
import org.apache.hadoop.hbase.testclassification.MediumTests; import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.junit.Ignore;
import org.junit.experimental.categories.Category; import org.junit.experimental.categories.Category;
@Category({ FlakeyTests.class, MediumTests.class }) @Category({ MediumTests.class })
// TODO: HBASE-19266 disables this test as the adaptive policy causes the negative size of MemStore
@Ignore
public class TestAcidGuaranteesWithAdaptivePolicy extends TestAcidGuaranteesWithNoInMemCompaction { public class TestAcidGuaranteesWithAdaptivePolicy extends TestAcidGuaranteesWithNoInMemCompaction {
@Override @Override

View File

@ -18,16 +18,11 @@
*/ */
package org.apache.hadoop.hbase; package org.apache.hadoop.hbase;
import org.apache.hadoop.hbase.testclassification.FlakeyTests;
import org.apache.hadoop.hbase.testclassification.MediumTests; import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.junit.Ignore;
import org.junit.experimental.categories.Category; import org.junit.experimental.categories.Category;
@Category({ FlakeyTests.class, MediumTests.class }) @Category({ MediumTests.class })
// TODO: HBASE-19266 disables this test as the eager policy causes the negative size of MemStore
@Ignore
public class TestAcidGuaranteesWithEagerPolicy extends TestAcidGuaranteesWithNoInMemCompaction { public class TestAcidGuaranteesWithEagerPolicy extends TestAcidGuaranteesWithNoInMemCompaction {
@Override @Override
protected MemoryCompactionPolicy getMemoryCompactionPolicy() { protected MemoryCompactionPolicy getMemoryCompactionPolicy() {
return MemoryCompactionPolicy.EAGER; return MemoryCompactionPolicy.EAGER;

View File

@ -34,8 +34,10 @@ import org.junit.After;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.Before; import org.junit.Before;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.experimental.categories.Category; import org.junit.experimental.categories.Category;
import org.junit.rules.TestRule;
import org.apache.hadoop.hbase.shaded.com.google.common.collect.Lists; import org.apache.hadoop.hbase.shaded.com.google.common.collect.Lists;
@ -46,7 +48,11 @@ import org.apache.hadoop.hbase.shaded.com.google.common.collect.Lists;
*/ */
@Category({ MediumTests.class }) @Category({ MediumTests.class })
public class TestAcidGuaranteesWithNoInMemCompaction { public class TestAcidGuaranteesWithNoInMemCompaction {
@Rule
public final TestRule timeout = CategoryBasedTimeout.builder()
.withTimeout(this.getClass())
.withLookingForStuckThread(true)
.build();
private static final HBaseTestingUtility UTIL = new HBaseTestingUtility(); private static final HBaseTestingUtility UTIL = new HBaseTestingUtility();
private AcidGuaranteesTestTool tool = new AcidGuaranteesTestTool(); private AcidGuaranteesTestTool tool = new AcidGuaranteesTestTool();