Use optimistic db

This commit is contained in:
Andrea Cavalli 2021-10-21 10:00:39 +02:00
parent 28920f2d02
commit 1f04241ac6
2 changed files with 5 additions and 2 deletions

View File

@ -45,6 +45,7 @@ import org.rocksdb.DbPath;
import org.rocksdb.FlushOptions;
import org.rocksdb.IndexType;
import org.rocksdb.OptimisticTransactionDB;
import org.rocksdb.OptimisticTransactionOptions;
import org.rocksdb.Options;
import org.rocksdb.RateLimiter;
import org.rocksdb.RocksDB;
@ -150,7 +151,7 @@ public class LLLocalKeyValueDatabase implements LLKeyValueDatabase {
while (true) {
try {
// a factory method that returns a RocksDB instance
this.db = TransactionDB.open(new DBOptions(rocksdbOptions), new TransactionDBOptions(), dbPathString, descriptors, handles);
this.db = OptimisticTransactionDB.open(new DBOptions(rocksdbOptions), dbPathString, descriptors, handles);
break;
} catch (RocksDBException ex) {
switch (ex.getMessage()) {
@ -452,12 +453,13 @@ public class LLLocalKeyValueDatabase implements LLKeyValueDatabase {
LinkedList<ColumnFamilyHandle> handles = new LinkedList<>();
this.db = TransactionDB.open(options, new TransactionDBOptions(), dbPathString);
this.db = RocksDB.open(options, dbPathString);
for (ColumnFamilyDescriptor columnFamilyDescriptor : descriptorsToCreate) {
handles.add(db.createColumnFamily(columnFamilyDescriptor));
}
flushAndCloseDb(db, handles);
this.db = null;
}
}

View File

@ -147,6 +147,7 @@ public final class OptimisticRocksDBColumn extends AbstractRocksDBColumn<Optimis
sentPrevData = prevData == null ? null : prevData.send();
sentCurData = newData == null ? null : newData.send();
if (!committedSuccessfully) {
tx.undoGetForUpdate(cfh, keyArray);
if (sentPrevData != null) {
sentPrevData.close();
}