Disable RocksDB checksum verification on reads (#5042)

* Add RocksDB readOptions with checksum verification set to false for RocksDB get methods
* Spotless + apply disabling checksum verification for unsegmented RocksDB reads

Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>
pull/5041/head
ahamlat 2 years ago committed by GitHub
parent e18e407c4e
commit 98f68ea1bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/segmented/RocksDBColumnarKeyValueStorage.java
  2. 3
      plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/segmented/RocksDBSnapshotTransaction.java
  3. 4
      plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/unsegmented/RocksDBKeyValueStorage.java

@ -56,6 +56,7 @@ import org.rocksdb.Env;
import org.rocksdb.LRUCache;
import org.rocksdb.OptimisticTransactionDB;
import org.rocksdb.Options;
import org.rocksdb.ReadOptions;
import org.rocksdb.RocksDB;
import org.rocksdb.RocksDBException;
import org.rocksdb.RocksIterator;
@ -90,6 +91,7 @@ public class RocksDBColumnarKeyValueStorage
private final RocksDBMetrics metrics;
private final WriteOptions tryDeleteOptions =
new WriteOptions().setNoSlowdown(true).setIgnoreMissingColumnFamilies(true);
private final ReadOptions readOptions = new ReadOptions().setVerifyChecksums(false);
/**
* Instantiates a new RocksDb columnar key value storage.
@ -249,7 +251,7 @@ public class RocksDBColumnarKeyValueStorage
throwIfClosed();
try (final OperationTimer.TimingContext ignored = metrics.getReadLatency().startTimer()) {
return Optional.ofNullable(db.get(segment.get(), key));
return Optional.ofNullable(db.get(segment.get(), readOptions, key));
} catch (final RocksDBException e) {
throw new StorageException(e);
}

@ -67,7 +67,8 @@ public class RocksDBSnapshotTransaction implements KeyValueStorageTransaction, A
this.snapshot = new RocksDBSnapshot(db);
this.writeOptions = new WriteOptions();
this.snapTx = db.beginTransaction(writeOptions);
this.readOptions = new ReadOptions().setSnapshot(snapshot.markAndUseSnapshot());
this.readOptions =
new ReadOptions().setVerifyChecksums(false).setSnapshot(snapshot.markAndUseSnapshot());
}
private RocksDBSnapshotTransaction(

@ -39,6 +39,7 @@ import org.rocksdb.BlockBasedTableConfig;
import org.rocksdb.LRUCache;
import org.rocksdb.OptimisticTransactionDB;
import org.rocksdb.Options;
import org.rocksdb.ReadOptions;
import org.rocksdb.RocksDBException;
import org.rocksdb.RocksIterator;
import org.rocksdb.Statistics;
@ -62,6 +63,7 @@ public class RocksDBKeyValueStorage implements KeyValueStorage {
private final RocksDBMetrics rocksDBMetrics;
private final WriteOptions tryDeleteOptions =
new WriteOptions().setNoSlowdown(true).setIgnoreMissingColumnFamilies(true);
private final ReadOptions readOptions = new ReadOptions().setVerifyChecksums(false);
/**
* Instantiates a new Rocks db key value storage.
@ -122,7 +124,7 @@ public class RocksDBKeyValueStorage implements KeyValueStorage {
try (final OperationTimer.TimingContext ignored =
rocksDBMetrics.getReadLatency().startTimer()) {
return Optional.ofNullable(db.get(key));
return Optional.ofNullable(db.get(readOptions, key));
} catch (final RocksDBException e) {
throw new StorageException(e);
}

Loading…
Cancel
Save