From 7fcc1d0ddff2d1a4543b2b6201e319c8140f3b2f Mon Sep 17 00:00:00 2001 From: Sagar Vemuri Date: Fri, 26 Jan 2018 11:01:54 -0800 Subject: [PATCH] Incorrect Universal Compaction reason Summary: While writing tests for dynamic Universal Compaction options, I found that the compaction reasons we set for size-ratio based and sorted-run based universal compactions are swapped with each other. Fixed it. Closes https://github.com/facebook/rocksdb/pull/3412 Differential Revision: D6820540 Pulled By: sagar0 fbshipit-source-id: 270a188968ba25b2c96a8339904416c4c87ff5b3 --- db/compaction_picker_universal.cc | 4 ++-- db/listener_test.cc | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/db/compaction_picker_universal.cc b/db/compaction_picker_universal.cc index 9975ef80c..960c65d2b 100644 --- a/db/compaction_picker_universal.cc +++ b/db/compaction_picker_universal.cc @@ -603,9 +603,9 @@ Compaction* UniversalCompactionPicker::PickCompactionToReduceSortedRuns( CompactionReason compaction_reason; if (max_number_of_files_to_compact == UINT_MAX) { - compaction_reason = CompactionReason::kUniversalSortedRunNum; - } else { compaction_reason = CompactionReason::kUniversalSizeRatio; + } else { + compaction_reason = CompactionReason::kUniversalSortedRunNum; } return new Compaction( vstorage, ioptions_, mutable_cf_options, std::move(inputs), output_level, diff --git a/db/listener_test.cc b/db/listener_test.cc index 5b5f2266b..86646fdde 100644 --- a/db/listener_test.cc +++ b/db/listener_test.cc @@ -528,7 +528,7 @@ TEST_F(EventListenerTest, CompactionReasonUniversal) { ASSERT_GT(listener->compaction_reasons_.size(), 0); for (auto compaction_reason : listener->compaction_reasons_) { - ASSERT_EQ(compaction_reason, CompactionReason::kUniversalSortedRunNum); + ASSERT_EQ(compaction_reason, CompactionReason::kUniversalSizeRatio); } options.level0_file_num_compaction_trigger = 8;