diff --git a/db/db_impl.cc b/db/db_impl.cc index b61ea303d..d8df10c5a 100644 --- a/db/db_impl.cc +++ b/db/db_impl.cc @@ -1727,9 +1727,37 @@ Status DBImpl::CompactRange(ColumnFamilyHandle* column_family, bool DBImpl::SetOptions(ColumnFamilyHandle* column_family, const std::unordered_map& options_map) { - auto cfh = reinterpret_cast(column_family); - MutexLock l(&mutex_); - return cfh->cfd()->SetOptions(options_map); + auto* cfd = reinterpret_cast(column_family)->cfd(); + if (options_map.empty()) { + Log(db_options_.info_log, "SetOptions() on column family [%s], empty input", + cfd->GetName().c_str()); + return false; + } + + MutableCFOptions new_options; + bool succeed = false; + { + MutexLock l(&mutex_); + if (cfd->SetOptions(options_map)) { + new_options = *cfd->GetLatestMutableCFOptions(); + succeed = true; + } + } + + Log(db_options_.info_log, "SetOptions() on column family [%s], inputs:", + cfd->GetName().c_str()); + for (const auto& o : options_map) { + Log(db_options_.info_log, "%s: %s\n", o.first.c_str(), o.second.c_str()); + } + if (succeed) { + Log(db_options_.info_log, "[%s] SetOptions succeeded", + cfd->GetName().c_str()); + new_options.Dump(db_options_.info_log.get()); + } else { + Log(db_options_.info_log, "[%s] SetOptions failed", + cfd->GetName().c_str()); + } + return succeed; } // return the same level if it cannot be moved diff --git a/util/mutable_cf_options.cc b/util/mutable_cf_options.cc index 1c710c656..f6a2933d3 100644 --- a/util/mutable_cf_options.cc +++ b/util/mutable_cf_options.cc @@ -3,8 +3,15 @@ // LICENSE file in the root directory of this source tree. An additional grant // of patent rights can be found in the PATENTS file in the same directory. +#ifndef __STDC_FORMAT_MACROS +#define __STDC_FORMAT_MACROS +#endif + +#include #include #include +#include +#include "rocksdb/env.h" #include "rocksdb/options.h" #include "rocksdb/immutable_options.h" #include "util/mutable_cf_options.h" @@ -69,4 +76,58 @@ uint64_t MutableCFOptions::ExpandedCompactionByteSizeLimit(int level) const { return MaxFileSizeForLevel(level) * expanded_compaction_factor; } +void MutableCFOptions::Dump(Logger* log) const { + // Memtable related options + Log(log, " write_buffer_size: %" PRIu64, + write_buffer_size); + Log(log, " max_write_buffer_number: %d", + max_write_buffer_number); + Log(log, " arena_block_size: %" PRIu64, + arena_block_size); + Log(log, " memtable_prefix_bloom_bits: %" PRIu32, + memtable_prefix_bloom_bits); + Log(log, " memtable_prefix_bloom_probes: %" PRIu32, + memtable_prefix_bloom_probes); + Log(log, " memtable_prefix_bloom_huge_page_tlb_size: %" PRIu64, + memtable_prefix_bloom_huge_page_tlb_size); + Log(log, " max_successive_merges: %" PRIu64, + max_successive_merges); + Log(log, " filter_deletes: %d", + filter_deletes); + Log(log, " disable_auto_compactions: %d", + disable_auto_compactions); + Log(log, " soft_rate_limit: %lf", + soft_rate_limit); + Log(log, " hard_rate_limit: %lf", + hard_rate_limit); + Log(log, " level0_file_num_compaction_trigger: %d", + level0_file_num_compaction_trigger); + Log(log, " level0_slowdown_writes_trigger: %d", + level0_slowdown_writes_trigger); + Log(log, " level0_stop_writes_trigger: %d", + level0_stop_writes_trigger); + Log(log, " max_grandparent_overlap_factor: %d", + max_grandparent_overlap_factor); + Log(log, " expanded_compaction_factor: %d", + expanded_compaction_factor); + Log(log, " source_compaction_factor: %d", + source_compaction_factor); + Log(log, " target_file_size_base: %d", + target_file_size_base); + Log(log, " target_file_size_multiplier: %d", + target_file_size_multiplier); + Log(log, " max_bytes_for_level_base: %" PRIu64, + max_bytes_for_level_base); + Log(log, " max_bytes_for_level_multiplier: %d", + max_bytes_for_level_multiplier); + std::string result; + char buf[10]; + for (const auto m : max_bytes_for_level_multiplier_additional) { + snprintf(buf, sizeof(buf), "%d, ", m); + result += buf; + } + result.resize(result.size() - 2); + Log(log, "max_bytes_for_level_multiplier_additional: %s", result.c_str()); +} + } // namespace rocksdb diff --git a/util/mutable_cf_options.h b/util/mutable_cf_options.h index bf340205d..eaecaa487 100644 --- a/util/mutable_cf_options.h +++ b/util/mutable_cf_options.h @@ -78,6 +78,8 @@ struct MutableCFOptions { uint64_t MaxGrandParentOverlapBytes(int level) const; uint64_t ExpandedCompactionByteSizeLimit(int level) const; + void Dump(Logger* log) const; + // Memtable related options size_t write_buffer_size; int max_write_buffer_number;