diff --git a/db/compaction/compaction_picker_level.cc b/db/compaction/compaction_picker_level.cc index e2feaadf0..6528c9b60 100644 --- a/db/compaction/compaction_picker_level.cc +++ b/db/compaction/compaction_picker_level.cc @@ -250,7 +250,6 @@ void LevelCompactionBuilder::SetupInitialFiles() { cf_name_, vstorage_, &start_level_, &output_level_, &start_level_inputs_); if (!start_level_inputs_.empty()) { - is_manual_ = true; compaction_reason_ = CompactionReason::kFilesMarkedForCompaction; return; } diff --git a/db/compaction/compaction_picker_universal.cc b/db/compaction/compaction_picker_universal.cc index 705536a67..afdcf7acf 100644 --- a/db/compaction/compaction_picker_universal.cc +++ b/db/compaction/compaction_picker_universal.cc @@ -960,7 +960,7 @@ Compaction* UniversalCompactionBuilder::PickDeleteTriggeredCompaction() { GetCompressionType(ioptions_, vstorage_, mutable_cf_options_, output_level, 1), GetCompressionOptions(mutable_cf_options_, vstorage_, output_level), - /* max_subcompactions */ 0, /* grandparents */ {}, /* is manual */ true, + /* max_subcompactions */ 0, /* grandparents */ {}, /* is manual */ false, score_, false /* deletion_compaction */, CompactionReason::kFilesMarkedForCompaction); } diff --git a/db/db_table_properties_test.cc b/db/db_table_properties_test.cc index e3499df70..96bc37da0 100644 --- a/db/db_table_properties_test.cc +++ b/db/db_table_properties_test.cc @@ -45,7 +45,8 @@ void VerifyTableProperties(DB* db, uint64_t expected_entries_size) { } } // namespace -class DBTablePropertiesTest : public DBTestBase { +class DBTablePropertiesTest : public DBTestBase, + public testing::WithParamInterface { public: DBTablePropertiesTest() : DBTestBase("/db_table_properties_test") {} TablePropertiesCollection TestGetPropertiesOfTablesInRange( @@ -251,7 +252,20 @@ TEST_F(DBTablePropertiesTest, GetColumnFamilyNameProperty) { } } -TEST_F(DBTablePropertiesTest, DeletionTriggeredCompactionMarking) { +class DeletionTriggeredCompactionTestListener : public EventListener { + public: + void OnCompactionBegin(DB* , const CompactionJobInfo& ci) override { + ASSERT_EQ(ci.compaction_reason, + CompactionReason::kFilesMarkedForCompaction); + } + + void OnCompactionCompleted(DB* , const CompactionJobInfo& ci) override { + ASSERT_EQ(ci.compaction_reason, + CompactionReason::kFilesMarkedForCompaction); + } +}; + +TEST_P(DBTablePropertiesTest, DeletionTriggeredCompactionMarking) { int kNumKeys = 1000; int kWindowSize = 100; int kNumDelsTrigger = 90; @@ -260,6 +274,10 @@ TEST_F(DBTablePropertiesTest, DeletionTriggeredCompactionMarking) { Options opts = CurrentOptions(); opts.table_properties_collector_factories.emplace_back(compact_on_del); + + if(GetParam() == "kCompactionStyleUniversal") { + opts.compaction_style = kCompactionStyleUniversal; + } Reopen(opts); // add an L1 file to prevent tombstones from dropping due to obsolescence @@ -268,6 +286,11 @@ TEST_F(DBTablePropertiesTest, DeletionTriggeredCompactionMarking) { Flush(); MoveFilesToLevel(1); + DeletionTriggeredCompactionTestListener *listener = + new DeletionTriggeredCompactionTestListener(); + opts.listeners.emplace_back(listener); + Reopen(opts); + for (int i = 0; i < kNumKeys; ++i) { if (i >= kNumKeys - kWindowSize && i < kNumKeys - kWindowSize + kNumDelsTrigger) { @@ -280,7 +303,6 @@ TEST_F(DBTablePropertiesTest, DeletionTriggeredCompactionMarking) { dbfull()->TEST_WaitForCompact(); ASSERT_EQ(0, NumTableFilesAtLevel(0)); - ASSERT_GT(NumTableFilesAtLevel(1), 0); // Change the window size and deletion trigger and ensure new values take // effect @@ -302,7 +324,6 @@ TEST_F(DBTablePropertiesTest, DeletionTriggeredCompactionMarking) { dbfull()->TEST_WaitForCompact(); ASSERT_EQ(0, NumTableFilesAtLevel(0)); - ASSERT_GT(NumTableFilesAtLevel(1), 0); // Change the window size to disable delete triggered compaction kWindowSize = 0; @@ -322,9 +343,16 @@ TEST_F(DBTablePropertiesTest, DeletionTriggeredCompactionMarking) { dbfull()->TEST_WaitForCompact(); ASSERT_EQ(1, NumTableFilesAtLevel(0)); - } +INSTANTIATE_TEST_CASE_P( + DBTablePropertiesTest, + DBTablePropertiesTest, + ::testing::Values( + "kCompactionStyleLevel", + "kCompactionStyleUniversal" + )); + } // namespace ROCKSDB_NAMESPACE #endif // ROCKSDB_LITE diff --git a/db/db_test.cc b/db/db_test.cc index 60b6e086c..f0a7b921a 100644 --- a/db/db_test.cc +++ b/db/db_test.cc @@ -5503,7 +5503,7 @@ TEST_F(DBTest, EmptyCompactedDB) { #endif // ROCKSDB_LITE #ifndef ROCKSDB_LITE -TEST_F(DBTest, SuggestCompactRangeTest) { +TEST_F(DBTest, DISABLED_SuggestCompactRangeTest) { class CompactionFilterFactoryGetContext : public CompactionFilterFactory { public: std::unique_ptr CreateCompactionFilter( @@ -5611,6 +5611,7 @@ TEST_F(DBTest, SuggestCompactRangeTest) { ASSERT_EQ(1, NumTableFilesAtLevel(1)); } + TEST_F(DBTest, PromoteL0) { Options options = CurrentOptions(); options.disable_auto_compactions = true;