Fix the number of RocksDB log files to the last one week (#5428)

* Fix the number of RocksDB log files to 5 with 100 MB size for each LOG file

Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net
Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>

* Fix build issue

Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>

* spotless and add a changelog entry

Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>

* keep 1 week log files

Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>

* Update change log and fix the number of files

Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>

---------

Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net
Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>
Signed-off-by: ahamlat <ameziane.hamlat@consensys.net>
Co-authored-by: Fabio Di Fabio <fabio.difabio@consensys.net>
pull/5451/head
ahamlat 2 years ago committed by GitHub
parent 18405fc799
commit 276afeaabf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 43
      plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/segmented/RocksDBColumnarKeyValueStorage.java

@ -5,6 +5,7 @@
### Breaking Changes
### Additions and Improvements
- Set the retention policy for RocksDB log files to maintain only the logs from the last week [#5428](https://github.com/hyperledger/besu/pull/5428)
- "Big-EOF" (the EOF version initially slotted for Shanghai) has been moved from Cancun to FutureEIPs [#5429](https://github.com/hyperledger/besu/pull/5429)
- EIP-4844: Zero blob transactions are invalid [#5425](https://github.com/hyperledger/besu/pull/5425)
- Transaction pool flag to disable specific behaviors for locally submitted transactions [#5418](https://github.com/hyperledger/besu/pull/5418)

@ -78,6 +78,10 @@ public abstract class RocksDBColumnarKeyValueStorage
protected static final long ROCKSDB_BLOCKCACHE_SIZE_HIGH_SPEC = 1_073_741_824L;
/** RocksDb memtable size when using the high spec option */
protected static final long ROCKSDB_MEMTABLE_SIZE_HIGH_SPEC = 1_073_741_824L;
/** RocksDb number of log files to keep on disk */
private static final long NUMBER_OF_LOG_FILES_TO_KEEP = 7;
/** RocksDb Time to roll a log file (1 day = 3600 * 24 seconds) */
private static final long TIME_TO_ROLL_LOG_FILE = 86_400L;
static {
RocksDbUtil.loadNativeLibrary();
@ -165,28 +169,7 @@ public abstract class RocksDBColumnarKeyValueStorage
.setCompressionType(CompressionType.LZ4_COMPRESSION)
.setTableFormatConfig(createBlockBasedTableConfig(configuration))));
if (configuration.isHighSpec()) {
options =
new DBOptions()
.setCreateIfMissing(true)
.setMaxOpenFiles(configuration.getMaxOpenFiles())
.setDbWriteBufferSize(ROCKSDB_MEMTABLE_SIZE_HIGH_SPEC)
.setStatistics(stats)
.setCreateMissingColumnFamilies(true)
.setEnv(
Env.getDefault()
.setBackgroundThreads(configuration.getBackgroundThreadCount()));
} else {
options =
new DBOptions()
.setCreateIfMissing(true)
.setMaxOpenFiles(configuration.getMaxOpenFiles())
.setStatistics(stats)
.setCreateMissingColumnFamilies(true)
.setEnv(
Env.getDefault()
.setBackgroundThreads(configuration.getBackgroundThreadCount()));
}
setGlobalOptions(configuration, stats);
txOptions = new TransactionDBOptions();
columnHandles = new ArrayList<>(columnDescriptors.size());
@ -195,6 +178,22 @@ public abstract class RocksDBColumnarKeyValueStorage
}
}
private void setGlobalOptions(final RocksDBConfiguration configuration, final Statistics stats) {
options = new DBOptions();
options
.setCreateIfMissing(true)
.setMaxOpenFiles(configuration.getMaxOpenFiles())
.setStatistics(stats)
.setCreateMissingColumnFamilies(true)
.setLogFileTimeToRoll(TIME_TO_ROLL_LOG_FILE)
.setKeepLogFileNum(NUMBER_OF_LOG_FILES_TO_KEEP)
.setEnv(Env.getDefault().setBackgroundThreads(configuration.getBackgroundThreadCount()));
if (configuration.isHighSpec()) {
options.setDbWriteBufferSize(ROCKSDB_MEMTABLE_SIZE_HIGH_SPEC);
}
}
void initMetrics() {
metrics = rocksDBMetricsFactory.create(metricsSystem, configuration, getDB(), stats);
}

Loading…
Cancel
Save