From b54712ed7dae888bae2f4213f11069105d6615ab Mon Sep 17 00:00:00 2001 From: anand76 Date: Mon, 13 Apr 2020 19:56:02 -0700 Subject: [PATCH] Log CompactOnDeletionCollectorFactory parameters on DB open (#6686) Summary: Log it in the info log to help in troubleshooting. It is logged as follows - ``` 2020/04/10-10:51:39.886662 7ffff7fef340 Options.table_properties_collectors: CompactOnDeletionCollector (Sliding window size = 100 Deletion trigger = 90); ``` Tests: make check Pull Request resolved: https://github.com/facebook/rocksdb/pull/6686 Reviewed By: ltamasi Differential Revision: D21002442 Pulled By: anand1976 fbshipit-source-id: 7adf0dbae7f1febcb00ce61fea5097118ede5c6a --- include/rocksdb/table_properties.h | 5 +++++ include/rocksdb/utilities/table_properties_collectors.h | 8 +++++--- options/options.cc | 7 +++---- .../compact_on_deletion_collector.cc | 8 ++++++++ 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/include/rocksdb/table_properties.h b/include/rocksdb/table_properties.h index d0ac02310..213896f35 100644 --- a/include/rocksdb/table_properties.h +++ b/include/rocksdb/table_properties.h @@ -136,6 +136,11 @@ class TablePropertiesCollectorFactory { // The name of the properties collector can be used for debugging purpose. virtual const char* Name() const = 0; + + // Can be overridden by sub-classes to return the Name, followed by + // configuration info that will // be logged to the info log when the + // DB is opened + virtual std::string ToString() const { return Name(); } }; // TableProperties contains a bunch of read-only properties of its associated diff --git a/include/rocksdb/utilities/table_properties_collectors.h b/include/rocksdb/utilities/table_properties_collectors.h index b7ee88bc3..420bcbd4f 100644 --- a/include/rocksdb/utilities/table_properties_collectors.h +++ b/include/rocksdb/utilities/table_properties_collectors.h @@ -18,9 +18,9 @@ namespace ROCKSDB_NAMESPACE { class CompactOnDeletionCollectorFactory : public TablePropertiesCollectorFactory { public: - virtual ~CompactOnDeletionCollectorFactory() {} + ~CompactOnDeletionCollectorFactory() {} - virtual TablePropertiesCollector* CreateTablePropertiesCollector( + TablePropertiesCollector* CreateTablePropertiesCollector( TablePropertiesCollectorFactory::Context context) override; // Change the value of sliding_window_size "N" @@ -34,10 +34,12 @@ class CompactOnDeletionCollectorFactory deletion_trigger_.store(deletion_trigger); } - virtual const char* Name() const override { + const char* Name() const override { return "CompactOnDeletionCollector"; } + std::string ToString() const override; + private: friend std::shared_ptr NewCompactOnDeletionCollectorFactory(size_t sliding_window_size, diff --git a/options/options.cc b/options/options.cc index fe676597e..920b2002f 100644 --- a/options/options.cc +++ b/options/options.cc @@ -310,14 +310,13 @@ void ColumnFamilyOptions::Dump(Logger* log) const { ROCKS_LOG_HEADER(log, "Options.compaction_options_fifo.allow_compaction: %d", compaction_options_fifo.allow_compaction); - std::string collector_names; + std::ostringstream collector_info; for (const auto& collector_factory : table_properties_collector_factories) { - collector_names.append(collector_factory->Name()); - collector_names.append("; "); + collector_info << collector_factory->ToString() << ';'; } ROCKS_LOG_HEADER( log, " Options.table_properties_collectors: %s", - collector_names.c_str()); + collector_info.str().c_str()); ROCKS_LOG_HEADER(log, " Options.inplace_update_support: %d", inplace_update_support); diff --git a/utilities/table_properties_collectors/compact_on_deletion_collector.cc b/utilities/table_properties_collectors/compact_on_deletion_collector.cc index 89d666d4d..4fd688e9a 100644 --- a/utilities/table_properties_collectors/compact_on_deletion_collector.cc +++ b/utilities/table_properties_collectors/compact_on_deletion_collector.cc @@ -7,6 +7,7 @@ #include "utilities/table_properties_collectors/compact_on_deletion_collector.h" #include +#include #include "rocksdb/utilities/table_properties_collectors.h" namespace ROCKSDB_NAMESPACE { @@ -78,6 +79,13 @@ CompactOnDeletionCollectorFactory::CreateTablePropertiesCollector( sliding_window_size_.load(), deletion_trigger_.load()); } +std::string CompactOnDeletionCollectorFactory::ToString() const { + std::ostringstream cfg; + cfg << Name() << " (Sliding window size = " << sliding_window_size_.load() + << " Deletion trigger = " << deletion_trigger_.load() << ')'; + return cfg.str(); +} + std::shared_ptr NewCompactOnDeletionCollectorFactory( size_t sliding_window_size,