Add some comments for RocksDB option configuration (#22655)
This commit is contained in:
parent
eaf2df99c6
commit
c7ca2f41f5
|
@ -339,9 +339,6 @@ impl Rocks {
|
|||
warn!("Trying as secondary at : {:?}", secondary_path);
|
||||
warn!("This active secondary db use may temporarily cause the performance of another db use (like by validator) to degrade");
|
||||
|
||||
// This is needed according to https://github.com/facebook/rocksdb/wiki/Secondary-instance
|
||||
db_options.set_max_open_files(-1);
|
||||
|
||||
Rocks(
|
||||
DB::open_cf_as_secondary(
|
||||
&db_options,
|
||||
|
@ -1350,6 +1347,7 @@ fn get_cf_options<C: 'static + Column + ColumnName>(
|
|||
});
|
||||
}
|
||||
|
||||
// Disable automatic compactions in maintenance mode to prevent accidental cleaning
|
||||
if matches!(access_type, AccessType::PrimaryOnlyForMaintenance) {
|
||||
options.set_disable_auto_compactions(true);
|
||||
}
|
||||
|
@ -1359,13 +1357,15 @@ fn get_cf_options<C: 'static + Column + ColumnName>(
|
|||
|
||||
fn get_db_options(access_type: &AccessType) -> Options {
|
||||
let mut options = Options::default();
|
||||
|
||||
// Create missing items to support a clean start
|
||||
options.create_if_missing(true);
|
||||
options.create_missing_column_families(true);
|
||||
// A good value for this is the number of cores on the machine
|
||||
|
||||
// Per the docs, a good value for this is the number of cores on the machine
|
||||
options.increase_parallelism(num_cpus::get() as i32);
|
||||
|
||||
let mut env = rocksdb::Env::default().unwrap();
|
||||
|
||||
// While a compaction is ongoing, all the background threads
|
||||
// could be used by the compaction. This can stall writes which
|
||||
// need to flush the memtable. Add some high-priority background threads
|
||||
|
@ -1375,10 +1375,17 @@ fn get_db_options(access_type: &AccessType) -> Options {
|
|||
|
||||
// Set max total wal size to 4G.
|
||||
options.set_max_total_wal_size(4 * 1024 * 1024 * 1024);
|
||||
|
||||
// Disable automatic compactions in maintenance mode to prevent accidental cleaning
|
||||
if matches!(access_type, AccessType::PrimaryOnlyForMaintenance) {
|
||||
options.set_disable_auto_compactions(true);
|
||||
}
|
||||
|
||||
// Allow Rocks to open/keep open as many files as it needs for performance;
|
||||
// however, this is also explicitly required for a secondary instance.
|
||||
// See https://github.com/facebook/rocksdb/wiki/Secondary-instance
|
||||
options.set_max_open_files(-1);
|
||||
|
||||
options
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue