Fix crash

This commit is contained in:
Andrea Cavalli 2022-04-28 11:35:01 +02:00
parent c0d4dd0c22
commit e7718a8370
2 changed files with 23 additions and 10 deletions

View File

@ -868,6 +868,15 @@ public sealed abstract class AbstractRocksDBColumn<T extends RocksDB> implements
Buffer key, Buffer key,
BinarySerializationFunction updater, BinarySerializationFunction updater,
UpdateAtomicResultMode returnMode) throws IOException { UpdateAtomicResultMode returnMode) throws IOException {
if (!db.isOwningHandle()) {
throw new IllegalStateException("Database is closed");
}
if (!readOptions.isOwningHandle()) {
throw new IllegalStateException("ReadOptions is closed");
}
if (!cfh.isOwningHandle()) {
throw new IllegalStateException("Column family is closed");
}
try { try {
keyBufferSize.record(key.readableBytes()); keyBufferSize.record(key.readableBytes());
startedUpdate.increment(); startedUpdate.increment();

View File

@ -68,22 +68,16 @@ import org.rocksdb.DBOptions;
import org.rocksdb.DataBlockIndexType; import org.rocksdb.DataBlockIndexType;
import org.rocksdb.DbPath; import org.rocksdb.DbPath;
import org.rocksdb.Env; import org.rocksdb.Env;
import org.rocksdb.EnvOptions;
import org.rocksdb.FlushOptions; import org.rocksdb.FlushOptions;
import org.rocksdb.IndexType; import org.rocksdb.IndexType;
import org.rocksdb.InfoLogLevel; import org.rocksdb.InfoLogLevel;
import org.rocksdb.IngestExternalFileOptions; import org.rocksdb.IngestExternalFileOptions;
import org.rocksdb.LRUCache; import org.rocksdb.LRUCache;
import org.rocksdb.LevelMetaData;
import org.rocksdb.LiveFileMetaData;
import org.rocksdb.OptimisticTransactionDB; import org.rocksdb.OptimisticTransactionDB;
import org.rocksdb.PersistentCache; import org.rocksdb.PersistentCache;
import org.rocksdb.RocksDB; import org.rocksdb.RocksDB;
import org.rocksdb.RocksDB.LiveFiles;
import org.rocksdb.RocksDBException; import org.rocksdb.RocksDBException;
import org.rocksdb.Snapshot; import org.rocksdb.Snapshot;
import org.rocksdb.SstFileMetaData;
import org.rocksdb.SstFileWriter;
import org.rocksdb.TransactionDB; import org.rocksdb.TransactionDB;
import org.rocksdb.TransactionDBOptions; import org.rocksdb.TransactionDBOptions;
import org.rocksdb.TxnDBWritePolicy; import org.rocksdb.TxnDBWritePolicy;
@ -212,8 +206,10 @@ public class LLLocalKeyValueDatabase implements LLKeyValueDatabase {
: DEFAULT_COMPACTION_MEMTABLE_MEMORY_BUDGET)); : DEFAULT_COMPACTION_MEMTABLE_MEMORY_BUDGET));
} }
if (Boolean.parseBoolean(System.getProperty("it.cavallium.dbengine.compactions.auto.disable", "false"))) { if (isDisableAutoCompactions()) {
columnFamilyOptions.setDisableAutoCompactions(true); columnFamilyOptions.setDisableAutoCompactions(true);
columnFamilyOptions.setHardPendingCompactionBytesLimit(Long.MAX_VALUE);
columnFamilyOptions.setSoftPendingCompactionBytesLimit(Long.MAX_VALUE);
} }
boolean dynamicLevelBytes; boolean dynamicLevelBytes;
// This option is not supported with multiple db paths // This option is not supported with multiple db paths
@ -233,9 +229,13 @@ public class LLLocalKeyValueDatabase implements LLKeyValueDatabase {
// https://www.arangodb.com/docs/stable/programs-arangod-rocksdb.html // https://www.arangodb.com/docs/stable/programs-arangod-rocksdb.html
columnFamilyOptions.setMaxBytesForLevelMultiplier(10); columnFamilyOptions.setMaxBytesForLevelMultiplier(10);
} }
if (isDisableAutoCompactions()) {
columnFamilyOptions.setLevel0FileNumCompactionTrigger(-1);
} else {
// https://www.arangodb.com/docs/stable/programs-arangod-rocksdb.html // https://www.arangodb.com/docs/stable/programs-arangod-rocksdb.html
// Higher values speed up writes, but slow down reads // Higher values speed up writes, but slow down reads
columnFamilyOptions.setLevel0FileNumCompactionTrigger(2); columnFamilyOptions.setLevel0FileNumCompactionTrigger(2);
}
if (Boolean.parseBoolean(System.getProperty("it.cavallium.dbengine.disableslowdown", "false"))) { if (Boolean.parseBoolean(System.getProperty("it.cavallium.dbengine.disableslowdown", "false"))) {
columnFamilyOptions.setLevel0SlowdownWritesTrigger(-1); columnFamilyOptions.setLevel0SlowdownWritesTrigger(-1);
columnFamilyOptions.setLevel0StopWritesTrigger(Integer.MAX_VALUE); columnFamilyOptions.setLevel0StopWritesTrigger(Integer.MAX_VALUE);
@ -500,6 +500,10 @@ public class LLLocalKeyValueDatabase implements LLKeyValueDatabase {
registerGauge(meterRegistry, name, "rocksdb.bloom.filter.full.true.positive", false); registerGauge(meterRegistry, name, "rocksdb.bloom.filter.full.true.positive", false);
} }
private boolean isDisableAutoCompactions() {
return Boolean.parseBoolean(System.getProperty("it.cavallium.dbengine.compactions.auto.disable", "false"));
}
private synchronized PersistentCache resolvePersistentCache(HashMap<String, PersistentCache> caches, private synchronized PersistentCache resolvePersistentCache(HashMap<String, PersistentCache> caches,
DBOptions rocksdbOptions, DBOptions rocksdbOptions,
List<it.cavallium.dbengine.rpc.current.data.PersistentCache> persistentCaches, List<it.cavallium.dbengine.rpc.current.data.PersistentCache> persistentCaches,