diff --git a/db/compaction/compaction_job.cc b/db/compaction/compaction_job.cc index 35d6da36c30..f0d23f17441 100644 --- a/db/compaction/compaction_job.cc +++ b/db/compaction/compaction_job.cc @@ -54,7 +54,6 @@ #include "port/port.h" #include "rocksdb/db.h" #include "rocksdb/env.h" -#include "rocksdb/listener.h" #include "rocksdb/sst_partitioner.h" #include "rocksdb/statistics.h" #include "rocksdb/status.h" @@ -298,8 +297,6 @@ struct CompactionJob::SubcompactionState { return blob_garbage_meter->ProcessOutFlow(key, value); } - - bool IsPartialCompaction() { return start || end; } }; void CompactionJob::SubcompactionState::FillFilesToCutForTtl() { @@ -1235,19 +1232,6 @@ void CompactionJob::ProcessKeyValueCompaction(SubcompactionState* sub_compact) { ColumnFamilyData* cfd = sub_compact->compaction->column_family_data(); -#ifndef ROCKSDB_LITE - SubcompactionJobInfo info; - if (sub_compact->IsPartialCompaction()) { - info.cf_name = cfd->GetName(); - info.thread_id = env_->GetThreadID(); - info.base_input_level = sub_compact->compaction->start_level(); - info.output_level = sub_compact->compaction->output_level(); - for (auto listener : db_options_.listeners) { - listener->OnSubcompactionBegin(info); - } - } -#endif // !ROCKSDB_LITE - // Create compaction filter and fail the compaction if // IgnoreSnapshots() = false because it is not supported anymore const CompactionFilter* compaction_filter = @@ -1624,14 +1608,6 @@ void CompactionJob::ProcessKeyValueCompaction(SubcompactionState* sub_compact) { clip.reset(); raw_input.reset(); sub_compact->status = status; -#ifndef ROCKSDB_LITE - info.status = status; - if (sub_compact->IsPartialCompaction()) { - for (auto listener : db_options_.listeners) { - listener->OnSubcompactionCompleted(info); - } - } -#endif // !ROCKSDB_LITE } uint64_t CompactionJob::GetCompactionId(SubcompactionState* sub_compact) { diff --git a/db/listener_test.cc b/db/listener_test.cc index 629b1684b56..fd4470e3b6f 100644 --- a/db/listener_test.cc +++ b/db/listener_test.cc @@ -203,59 +203,6 @@ TEST_F(EventListenerTest, OnSingleDBCompactionTest) { } } -class TestSubcompactionListener : public EventListener { - public: - TestSubcompactionListener() : compacted_(0) {} - void OnSubcompactionCompleted(const SubcompactionJobInfo& /*si*/) override { - compacted_.fetch_add(1); - } - - std::atomic compacted_; -}; - -TEST_F(EventListenerTest, OnSingleDBSubcompactionTest) { - const int kNumL0Files = 8; - - Options options; - options.env = CurrentOptions().env; - options.create_if_missing = true; - options.max_subcompactions = 2; - options.compaction_style = kCompactionStyleLevel; - options.write_buffer_size = k110KB * 2; - options.target_file_size_base = options.write_buffer_size; - options.compression = kNoCompression; - options.level0_file_num_compaction_trigger = kNumL0Files; - options.table_properties_collector_factories.push_back( - std::make_shared()); - - TestSubcompactionListener* listener = new TestSubcompactionListener(); - options.listeners.emplace_back(listener); - Reopen(options); - ASSERT_OK(Put("k1", std::string(90000, 'k'))); - ASSERT_OK(Put("k4", std::string(90000, 'k'))); - ASSERT_OK(dbfull()->CompactRange( - CompactRangeOptions(), db_->DefaultColumnFamily(), nullptr, nullptr)); - // Three large files overlapped with L1 will trigger at least two - // subcompactions. - ASSERT_OK(Put("k1", std::string(90000, 'k'))); - ASSERT_OK(Put("k2", std::string(90000, 'k'))); - ASSERT_OK(Flush()); - ASSERT_OK(Put("k2", std::string(90000, 'k'))); - ASSERT_OK(Put("k3", std::string(90000, 'k'))); - ASSERT_OK(Flush()); - ASSERT_OK(Put("k3", std::string(90000, 'k'))); - ASSERT_OK(Put("k4", std::string(90000, 'k'))); - ASSERT_OK(Flush()); - ASSERT_OK(dbfull()->RunManualCompaction( - reinterpret_cast(db_->DefaultColumnFamily()) - ->cfd(), - 0 /* input_level */, 1 /* output_level */, CompactRangeOptions(), - nullptr /* begin */, nullptr /* end */, true /* exclusive */, - true /* disallow_trivial_move */, - port::kMaxUint64 /* max_file_num_to_ignore */)); - ASSERT_EQ(listener->compacted_.load(), 2); -} - // This simple Listener can only handle one flush at a time. class TestFlushListener : public EventListener { public: diff --git a/include/rocksdb/listener.h b/include/rocksdb/listener.h index ea3d0c5d051..b8db8e95d15 100644 --- a/include/rocksdb/listener.h +++ b/include/rocksdb/listener.h @@ -423,23 +423,6 @@ struct CompactionJobInfo { std::vector blob_file_garbage_infos; }; -struct SubcompactionJobInfo { - SubcompactionJobInfo() = default; - - // the id of the column family where the compaction happened. - uint32_t cf_id; - // the name of the column family where the compaction happened. - std::string cf_name; - // the status indicating whether the compaction was successful or not. - Status status; - // the id of the thread that completed this compaction job. - uint64_t thread_id; - // the smallest input level of the compaction. - int base_input_level; - // the output level of the compaction. - int output_level; -}; - struct MemTableInfo { // the name of the column family to which memtable belongs std::string cf_name; @@ -600,16 +583,6 @@ class EventListener : public Customizable { virtual void OnCompactionCompleted(DB* /*db*/, const CompactionJobInfo& /*ci*/) {} - // A callback function for RocksDB which will be called each time when - // a registered RocksDB uses multiple subcompactions to compact a file. The - // callback is called by each subcompaction and in the same thread. - virtual void OnSubcompactionBegin(const SubcompactionJobInfo& /*si*/) {} - - // A callback function for RocksDB which will be called each time when - // a registered RocksDB uses multiple subcompactions to compact a file. The - // callback is called by each subcompaction and in the same thread. - virtual void OnSubcompactionCompleted(const SubcompactionJobInfo& /*si*/) {} - // A callback function for RocksDB which will be called whenever // a SST file is created. Different from OnCompactionCompleted and // OnFlushCompleted, this callback is designed for external logging