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