Document SetOptions API (#9778)
Summary: much needed Some other minor tweaks also Pull Request resolved: https://github.com/facebook/rocksdb/pull/9778 Test Plan: existing tests Reviewed By: ajkr Differential Revision: D35258195 Pulled By: pdillinger fbshipit-source-id: 974ddafc23a540aacceb91da72e81593d818f99c
This commit is contained in:
parent
fd66005628
commit
105d7f0c7c
@ -1081,7 +1081,6 @@ Status DBImpl::SetOptions(
|
||||
MutableCFOptions new_options;
|
||||
Status s;
|
||||
Status persist_options_status;
|
||||
persist_options_status.PermitUncheckedError(); // Allow uninitialized access
|
||||
SuperVersionContext sv_context(/* create_superversion */ true);
|
||||
{
|
||||
auto db_options = GetDBOptions();
|
||||
@ -1117,9 +1116,11 @@ Status DBImpl::SetOptions(
|
||||
"[%s] SetOptions() succeeded", cfd->GetName().c_str());
|
||||
new_options.Dump(immutable_db_options_.info_log.get());
|
||||
if (!persist_options_status.ok()) {
|
||||
// NOTE: WriteOptionsFile already logs on failure
|
||||
s = persist_options_status;
|
||||
}
|
||||
} else {
|
||||
persist_options_status.PermitUncheckedError(); // less important
|
||||
ROCKS_LOG_WARN(immutable_db_options_.info_log, "[%s] SetOptions() failed",
|
||||
cfd->GetName().c_str());
|
||||
}
|
||||
|
@ -1201,20 +1201,44 @@ class DB {
|
||||
return CompactRange(options, DefaultColumnFamily(), begin, end);
|
||||
}
|
||||
|
||||
// TODO: documentation needed
|
||||
// NOTE: SetOptions is intended only for expert users, and does not apply the
|
||||
// same sanitization to options as the standard DB::Open code path does. Use
|
||||
// with caution.
|
||||
// Dynamically change column family options or table factory options in a
|
||||
// running DB, for the specified column family. Only options internally
|
||||
// marked as "mutable" can be changed. Options not listed in `opts_map` will
|
||||
// keep their current values. See GetColumnFamilyOptionsFromMap() in
|
||||
// convenience.h for the details of `opts_map`. Not supported in LITE mode.
|
||||
//
|
||||
// USABILITY NOTE: SetOptions is intended only for expert users, and does
|
||||
// not apply the same sanitization to options as the standard DB::Open code
|
||||
// path does. Use with caution.
|
||||
//
|
||||
// RELIABILITY & PERFORMANCE NOTE: SetOptions is not fully stress-tested for
|
||||
// reliability, and this is a slow call because a new OPTIONS file is
|
||||
// serialized and persisted for each call. Use only infrequently.
|
||||
//
|
||||
// EXAMPLES:
|
||||
// s = db->SetOptions(cfh, {{"ttl", "36000"}});
|
||||
// s = db->SetOptions(cfh, {{"block_based_table_factory",
|
||||
// "{prepopulate_block_cache=kDisable;}"}});
|
||||
virtual Status SetOptions(
|
||||
ColumnFamilyHandle* /*column_family*/,
|
||||
const std::unordered_map<std::string, std::string>& /*new_options*/) {
|
||||
const std::unordered_map<std::string, std::string>& /*opts_map*/) {
|
||||
return Status::NotSupported("Not implemented");
|
||||
}
|
||||
// Shortcut for SetOptions on the default column family handle.
|
||||
virtual Status SetOptions(
|
||||
const std::unordered_map<std::string, std::string>& new_options) {
|
||||
return SetOptions(DefaultColumnFamily(), new_options);
|
||||
}
|
||||
|
||||
// Like SetOptions but for DBOptions, including the same caveats for
|
||||
// usability, reliability, and performance. See GetDBOptionsFromMap() (and
|
||||
// GetColumnFamilyOptionsFromMap()) in convenience.h for details on
|
||||
// `opts_map`. Note supported in LITE mode.
|
||||
//
|
||||
// EXAMPLES:
|
||||
// s = db->SetDBOptions({{"max_subcompactions", "2"}});
|
||||
// s = db->SetDBOptions({{"stats_dump_period_sec", "0"},
|
||||
// {"stats_persist_period_sec", "0"}});
|
||||
virtual Status SetDBOptions(
|
||||
const std::unordered_map<std::string, std::string>& new_options) = 0;
|
||||
|
||||
@ -1299,6 +1323,8 @@ class DB {
|
||||
// Get Env object from the DB
|
||||
virtual Env* GetEnv() const = 0;
|
||||
|
||||
// A shortcut for GetEnv()->->GetFileSystem().get(), possibly cached for
|
||||
// efficiency.
|
||||
virtual FileSystem* GetFileSystem() const;
|
||||
|
||||
// Get DB Options that we use. During the process of opening the
|
||||
|
@ -738,11 +738,7 @@ ImmutableDBOptions::ImmutableDBOptions(const DBOptions& options)
|
||||
lowest_used_cache_tier(options.lowest_used_cache_tier),
|
||||
compaction_service(options.compaction_service) {
|
||||
fs = env->GetFileSystem();
|
||||
if (env != nullptr) {
|
||||
clock = env->GetSystemClock().get();
|
||||
} else {
|
||||
clock = SystemClock::Default().get();
|
||||
}
|
||||
clock = env->GetSystemClock().get();
|
||||
logger = info_log.get();
|
||||
stats = statistics.get();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user