[rocksdb/speedb] Define keep_log_file_num. Default to 20 (#3064)

This commit is contained in:
Salvador Girones Gil 2023-12-04 13:17:27 +01:00 committed by GitHub
parent 07a0087c1b
commit e4aa85a843
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 0 deletions

View file

@ -55,3 +55,10 @@ pub static ROCKSDB_MIN_BLOB_SIZE: Lazy<u64> = Lazy::new(|| {
.map(|v| v.parse::<u64>().unwrap_or(default))
.unwrap_or(default)
});
pub static ROCKSDB_KEEP_LOG_FILE_NUM: Lazy<usize> = Lazy::new(|| {
let default = 20;
std::env::var("SURREAL_ROCKSDB_KEEP_LOG_FILE_NUM")
.map(|v| v.parse::<usize>().unwrap_or(default))
.unwrap_or(default)
});

View file

@ -79,6 +79,8 @@ impl Datastore {
opts.set_use_fsync(false);
// Only use warning log level
opts.set_log_level(LogLevel::Warn);
// Set the number of log files to keep
opts.set_keep_log_file_num(*cnf::ROCKSDB_KEEP_LOG_FILE_NUM);
// Create database if missing
opts.create_if_missing(true);
// Create column families if missing

View file

@ -55,3 +55,10 @@ pub static SPEEDB_MIN_BLOB_SIZE: Lazy<u64> = Lazy::new(|| {
.map(|v| v.parse::<u64>().unwrap_or(default))
.unwrap_or(default)
});
pub static SPEEDB_KEEP_LOG_FILE_NUM: Lazy<usize> = Lazy::new(|| {
let default = 20;
std::env::var("SURREAL_SPEEDB_KEEP_LOG_FILE_NUM")
.map(|v| v.parse::<usize>().unwrap_or(default))
.unwrap_or(default)
});

View file

@ -79,6 +79,8 @@ impl Datastore {
opts.set_use_fsync(false);
// Only use warning log level
opts.set_log_level(LogLevel::Warn);
// Set the number of log files to keep
opts.set_keep_log_file_num(*cnf::SPEEDB_KEEP_LOG_FILE_NUM);
// Create database if missing
opts.create_if_missing(true);
// Create column families if missing