diff --git a/db/compaction/subcompaction_state.h b/db/compaction/subcompaction_state.h index 13e63120f..c748be31b 100644 --- a/db/compaction/subcompaction_state.h +++ b/db/compaction/subcompaction_state.h @@ -196,8 +196,11 @@ class SubcompactionState { const CompactionFileCloseFunc& close_file_func) { // Call FinishCompactionOutputFile() even if status is not ok: it needs to // close the output file. + // CloseOutput() may open new compaction output files. + is_current_penultimate_level_ = true; Status s = penultimate_level_outputs_.CloseOutput( curr_status, open_file_func, close_file_func); + is_current_penultimate_level_ = false; s = compaction_outputs_.CloseOutput(s, open_file_func, close_file_func); return s; } diff --git a/db/compaction/tiered_compaction_test.cc b/db/compaction/tiered_compaction_test.cc index aaebcfd94..b541b1d10 100644 --- a/db/compaction/tiered_compaction_test.cc +++ b/db/compaction/tiered_compaction_test.cc @@ -663,8 +663,19 @@ TEST_P(TieredCompactionTest, LevelOutofBoundaryRangeDelete) { cro.bottommost_level_compaction = BottommostLevelCompaction::kForce; ASSERT_OK(db_->CompactRange(cro, nullptr, nullptr)); - ASSERT_EQ(GetSstSizeHelper(Temperature::kUnknown), - 0); // tombstone has no size, even it's in hot tier + // range tombstone is not in cold tier + ASSERT_GT(GetSstSizeHelper(Temperature::kUnknown), 0); + std::vector> level_to_files; + dbfull()->TEST_GetFilesMetaData(dbfull()->DefaultColumnFamily(), + &level_to_files); + // range tombstone is in the penultimate level + const int penultimate_level = kNumLevels - 2; + ASSERT_EQ(level_to_files[penultimate_level].size(), 1); + ASSERT_EQ(level_to_files[penultimate_level][0].num_entries, 1); + ASSERT_EQ(level_to_files[penultimate_level][0].num_deletions, 1); + ASSERT_EQ(level_to_files[penultimate_level][0].temperature, + Temperature::kUnknown); + ASSERT_GT(GetSstSizeHelper(Temperature::kCold), 0); ASSERT_EQ("0,1,10", FilesPerLevel()); // one file is at the penultimate level which