From 8d390c93fc58633d1bcd3b6514d92dd49559a508 Mon Sep 17 00:00:00 2001 From: Andrew Toth Date: Sat, 21 Mar 2026 11:20:48 -0400 Subject: [PATCH] dbwrapper: make max_file_size a configurable DBParams field Useful for fuzzing different values. --- src/dbwrapper.cpp | 2 +- src/dbwrapper.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/dbwrapper.cpp b/src/dbwrapper.cpp index eb222078b5e..ee6419d2041 100644 --- a/src/dbwrapper.cpp +++ b/src/dbwrapper.cpp @@ -149,7 +149,6 @@ static leveldb::Options GetOptions(size_t nCacheSize) // on corruption in later versions. options.paranoid_checks = true; } - options.max_file_size = std::max(options.max_file_size, DBWRAPPER_MAX_FILE_SIZE); SetMaxOpenFiles(&options); return options; } @@ -224,6 +223,7 @@ CDBWrapper::CDBWrapper(const DBParams& params) DBContext().syncoptions.sync = true; DBContext().options = GetOptions(params.cache_bytes); DBContext().options.create_if_missing = true; + DBContext().options.max_file_size = params.max_file_size; if (params.memory_only) { DBContext().penv = leveldb::NewMemEnv(leveldb::Env::Default()); DBContext().options.env = DBContext().penv; diff --git a/src/dbwrapper.h b/src/dbwrapper.h index 2eee6c1c023..c36864004fd 100644 --- a/src/dbwrapper.h +++ b/src/dbwrapper.h @@ -44,6 +44,9 @@ struct DBParams { bool obfuscate = false; //! Passed-through options. DBOptions options{}; + //! Maximum LevelDB SST file size. Larger values reduce the frequency + //! of compactions but increase their duration. + size_t max_file_size = DBWRAPPER_MAX_FILE_SIZE; }; class dbwrapper_error : public std::runtime_error