Permalink
Browse files

Upgrade to BDB 4.1.17, to fix GC issues

  • Loading branch information...
1 parent a466222 commit 5a06c3f35c5cc04dd884f3b296f0278f89aa5862 @ctasada committed May 16, 2012
@@ -22,7 +22,6 @@
import java.util.List;
import java.util.Properties;
-import org.mockito.internal.verification.Times;
import voldemort.client.protocol.RequestFormatType;
import voldemort.cluster.failuredetector.FailureDetectorConfig;
import voldemort.server.scheduler.slop.StreamingSlopPusherJob;
@@ -72,13 +71,16 @@
private int bdbCleanerMinUtilization;
private int bdbCleanerLookAheadCacheSize;
private boolean bdbCheckpointerHighPriority;
+ private boolean bdbCleanerLazyMigration;
private int bdbCleanerMaxBatchFiles;
private boolean bdbReadUncommitted;
private int bdbCleanerThreads;
private long bdbLockTimeoutMs;
private int bdbLockNLockTables;
private boolean bdbFairLatches;
private long bdbStatsCacheTtlMs;
+ private boolean bdbCacheModeEvictLN;
+ private boolean bdbMinimizeScanImpact;
private String mysqlUsername;
private String mysqlPassword;
@@ -208,9 +210,12 @@ public VoldemortConfig(Props props) {
this.bdbLockNLockTables = props.getInt("bdb.lock.nLockTables", 1);
this.bdbFairLatches = props.getBoolean("bdb.fair.latches", false);
this.bdbCheckpointerHighPriority = props.getBoolean("bdb.checkpointer.high.priority", false);
+ this.bdbCleanerLazyMigration = props.getBoolean("bdb.cleaner.lazy.migration", true);
this.bdbCleanerMaxBatchFiles = props.getInt("bdb.cleaner.max.batch.files", 0);
this.bdbReadUncommitted = props.getBoolean("bdb.lock.read_uncommitted", true);
this.bdbStatsCacheTtlMs = props.getLong("bdb.stats.cache.ttl.ms", 5 * Time.MS_PER_SECOND);
+ this.bdbCacheModeEvictLN = props.getBoolean("bdb.cache.evictln", false);
+ this.bdbMinimizeScanImpact = props.getBoolean("bdb.minimize.scan.impact", false);
this.readOnlyBackups = props.getInt("readonly.backups", 1);
this.readOnlySearchStrategy = props.getString("readonly.search.strategy",
@@ -563,6 +568,25 @@ public final void setBdbCheckpointerHighPriority(boolean bdbCheckpointerHighPrio
}
/**
+ * If true, Cleaner offloads some work to application threads, to keep up
+ * with the write rate.
+ *
+ * <ul>
+ * <li>property: "bdb.cleaner.lazy.migration"</li>
+ * <li>default : true</li>
+ * </ul>
+ *
+ * @return
+ */
+ public boolean getBdbCleanerLazyMigration() {
+ return bdbCleanerLazyMigration;
+ }
+
+ public final void setBdbCleanerLazyMigration(boolean bdbCleanerLazyMigration) {
+ this.bdbCleanerLazyMigration = bdbCleanerLazyMigration;
+ }
+
+ /**
* The maximum number of log files in the cleaner's backlog, or zero if
* there is no limit
*
@@ -698,6 +722,43 @@ public void setBdbBtreeFanout(int bdbBtreeFanout) {
}
/**
+ * If true, BDB will not cache data in the JVM.
+ *
+ * <ul>
+ * <li>Property : "bdb.cache.evictln"</li>
+ * <li>Default : false</li>
+ * </ul>
+ *
+ * @return
+ */
+ public boolean getBdbCacheModeEvictLN() {
+ return bdbCacheModeEvictLN;
+ }
+
+ public void setBdbCacheModeEvictLN(boolean bdbCacheModeEvictLN) {
+ this.bdbCacheModeEvictLN = bdbCacheModeEvictLN;
+ }
+
+ /**
+ * If true, attempts are made to minimize impact to BDB cache during scan
+ * jobs
+ *
+ * <ul>
+ * <li>Property : "bdb.minimize.scan.impact"</li>
+ * <li>Default : false</li>
+ * </ul>
+ *
+ * @return
+ */
+ public boolean getBdbMinimizeScanImpact() {
+ return bdbMinimizeScanImpact;
+ }
+
+ public void setBdbMinimizeScanImpact(boolean bdbMinimizeScanImpact) {
+ this.bdbMinimizeScanImpact = bdbMinimizeScanImpact;
+ }
+
+ /**
* The comfortable number of threads the threadpool will attempt to
* maintain. Specified by "core.threads" default: max(1, floor(0.5 *
* max.threads))
@@ -44,6 +44,7 @@
import voldemort.server.storage.StorageService;
import voldemort.store.configuration.ConfigurationStorageEngine;
import voldemort.store.metadata.MetadataStore;
+import voldemort.utils.JNAUtils;
import voldemort.utils.RebalanceUtils;
import voldemort.utils.SystemTime;
import voldemort.utils.Utils;
@@ -207,6 +208,8 @@ public AsyncOperationService getAsyncRunner() {
@Override
protected void startInner() throws VoldemortException {
+ // lock down jvm heap
+ JNAUtils.tryMlockall();
logger.info("Starting " + services.size() + " services.");
long start = System.currentTimeMillis();
for(VoldemortService service: services)
@@ -239,6 +242,8 @@ protected void stopInner() throws VoldemortException {
if(exceptions.size() > 0)
throw exceptions.get(0);
+ // release lock of jvm heap
+ JNAUtils.tryMunlockall();
}
public static void main(String[] args) throws Exception {
@@ -38,7 +38,6 @@
import voldemort.store.Store;
import voldemort.store.bdb.BdbStorageEngine;
import voldemort.store.bdb.stats.BdbEnvironmentStats;
-import voldemort.store.bdb.stats.BdbSpaceStats;
import voldemort.utils.ByteArray;
import voldemort.utils.JmxUtils;
@@ -88,9 +87,6 @@ protected void startInner() {
registerBean(bdbStore.getBdbEnvironmentStats(),
JmxUtils.createObjectName(JmxUtils.getPackageName(BdbEnvironmentStats.class),
store.getName()));
- registerBean(bdbStore.getBdbSpaceStats(),
- JmxUtils.createObjectName(JmxUtils.getPackageName(BdbSpaceStats.class),
- store.getName()));
}
}
}
@@ -1,9 +1,10 @@
package voldemort.store.bdb;
-import com.sleepycat.je.LockMode;
import voldemort.server.VoldemortConfig;
import voldemort.utils.Time;
+import com.sleepycat.je.LockMode;
+
/**
* Runtime (i.e., post Environment creation) configuration for BdbStorageEngine
*
@@ -12,9 +13,11 @@
public static final long DEFAULT_STATS_CACHE_TTL_MS = 5 * Time.MS_PER_SECOND;
public static final LockMode DEFAULT_LOCK_MODE = LockMode.READ_UNCOMMITTED;
+ public static final boolean DEFAULT_MINIMIZE_SCAN_IMPACT = false;
private long statsCacheTtlMs = DEFAULT_STATS_CACHE_TTL_MS;
private LockMode lockMode = DEFAULT_LOCK_MODE;
+ private boolean minimizeScanImpact = DEFAULT_MINIMIZE_SCAN_IMPACT;
public BdbRuntimeConfig() {
@@ -25,6 +28,7 @@ public BdbRuntimeConfig(VoldemortConfig config) {
: LockMode.DEFAULT;
setLockMode(lockMode);
setStatsCacheTtlMs(config.getBdbStatsCacheTtlMs());
+ setMinimizeScanImpact(config.getBdbMinimizeScanImpact());
}
public long getStatsCacheTtlMs() {
@@ -44,4 +48,12 @@ public BdbRuntimeConfig setLockMode(LockMode lockMode) {
this.lockMode = lockMode;
return this;
}
+
+ public boolean getMinimizeScanImpact() {
+ return minimizeScanImpact;
+ }
+
+ public void setMinimizeScanImpact(boolean minimizeScanImpact) {
+ this.minimizeScanImpact = minimizeScanImpact;
+ }
}
@@ -31,17 +31,17 @@
import voldemort.utils.ByteArray;
import voldemort.utils.Time;
+import com.google.common.collect.Maps;
+import com.sleepycat.je.CacheMode;
import com.sleepycat.je.Database;
import com.sleepycat.je.DatabaseConfig;
import com.sleepycat.je.DatabaseException;
+import com.sleepycat.je.Durability;
import com.sleepycat.je.Environment;
import com.sleepycat.je.EnvironmentConfig;
import com.sleepycat.je.EnvironmentStats;
-import com.sleepycat.je.PreloadConfig;
import com.sleepycat.je.StatsConfig;
-import com.google.common.collect.Maps;
-
/**
* The configuration that is shared between berkeley db instances. This includes
* the db environment and the configuration
@@ -70,13 +70,11 @@ public BdbStorageConfiguration(VoldemortConfig config) {
environmentConfig.setTransactional(true);
environmentConfig.setCacheSize(config.getBdbCacheSize());
if(config.isBdbWriteTransactionsEnabled() && config.isBdbFlushTransactionsEnabled()) {
- environmentConfig.setTxnNoSync(false);
- environmentConfig.setTxnWriteNoSync(false);
+ environmentConfig.setDurability(Durability.COMMIT_SYNC);
} else if(config.isBdbWriteTransactionsEnabled() && !config.isBdbFlushTransactionsEnabled()) {
- environmentConfig.setTxnNoSync(false);
- environmentConfig.setTxnWriteNoSync(true);
+ environmentConfig.setDurability(Durability.COMMIT_WRITE_NO_SYNC);
} else {
- environmentConfig.setTxnNoSync(true);
+ environmentConfig.setDurability(Durability.COMMIT_NO_SYNC);
}
environmentConfig.setAllowCreate(true);
environmentConfig.setConfigParam(EnvironmentConfig.LOG_FILE_MAX,
@@ -101,8 +99,13 @@ public BdbStorageConfiguration(VoldemortConfig config) {
Boolean.toString(config.getBdbCheckpointerHighPriority()));
environmentConfig.setConfigParam(EnvironmentConfig.CLEANER_MAX_BATCH_FILES,
Integer.toString(config.getBdbCleanerMaxBatchFiles()));
+ environmentConfig.setConfigParam(EnvironmentConfig.CLEANER_LAZY_MIGRATION,
+ Boolean.toString(config.getBdbCleanerLazyMigration()));
environmentConfig.setLockTimeout(config.getBdbLockTimeoutMs(), TimeUnit.MILLISECONDS);
+ if(config.getBdbCacheModeEvictLN()) {
+ environmentConfig.setCacheMode(CacheMode.EVICT_LN);
+ }
databaseConfig = new DatabaseConfig();
databaseConfig.setAllowCreate(true);
databaseConfig.setSortedDuplicates(config.isBdbSortedDuplicatesEnabled());
@@ -36,7 +36,6 @@
import voldemort.store.StoreCapabilityType;
import voldemort.store.StoreUtils;
import voldemort.store.bdb.stats.BdbEnvironmentStats;
-import voldemort.store.bdb.stats.BdbSpaceStats;
import voldemort.utils.ByteArray;
import voldemort.utils.ByteUtils;
import voldemort.utils.ClosableIterator;
@@ -49,6 +48,7 @@
import voldemort.versioning.Versioned;
import com.google.common.collect.Lists;
+import com.sleepycat.je.CacheMode;
import com.sleepycat.je.Cursor;
import com.sleepycat.je.Database;
import com.sleepycat.je.DatabaseEntry;
@@ -78,8 +78,8 @@
private final LockMode readLockMode;
private final Serializer<Version> versionSerializer;
private final BdbEnvironmentStats bdbEnvironmentStats;
- private final BdbSpaceStats bdbSpaceStats;
private final AtomicBoolean isTruncating = new AtomicBoolean(false);
+ private final boolean minimizeScanImpact;
public BdbStorageEngine(String name,
Environment environment,
@@ -102,7 +102,7 @@ public Version toObject(byte[] bytes) {
this.isOpen = new AtomicBoolean(true);
this.readLockMode = config.getLockMode();
this.bdbEnvironmentStats = new BdbEnvironmentStats(environment, config.getStatsCacheTtlMs());
- this.bdbSpaceStats = new BdbSpaceStats(environment, config.getStatsCacheTtlMs());
+ this.minimizeScanImpact = config.getMinimizeScanImpact();
}
public String getName() {
@@ -112,6 +112,9 @@ public String getName() {
public ClosableIterator<Pair<ByteArray, Versioned<byte[]>>> entries() {
try {
Cursor cursor = getBdbDatabase().openCursor(null, null);
+ // evict data brought in by the cursor walk right away
+ if(this.minimizeScanImpact)
+ cursor.setCacheMode(CacheMode.EVICT_BIN);
return new BdbEntriesIterator(cursor);
} catch(DatabaseException e) {
logger.error(e);
@@ -122,6 +125,9 @@ public String getName() {
public ClosableIterator<ByteArray> keys() {
try {
Cursor cursor = getBdbDatabase().openCursor(null, null);
+ // evict data brought in by the cursor walk right away
+ if(this.minimizeScanImpact)
+ cursor.setCacheMode(CacheMode.EVICT_BIN);
return new BdbKeysIterator(cursor);
} catch(DatabaseException e) {
logger.error(e);
@@ -449,9 +455,6 @@ public BdbEnvironmentStats getBdbEnvironmentStats() {
return bdbEnvironmentStats;
}
- public BdbSpaceStats getBdbSpaceStats() {
- return bdbSpaceStats;
- }
private static abstract class BdbIterator<T> implements ClosableIterator<T> {
Oops, something went wrong.

0 comments on commit 5a06c3f

Please sign in to comment.