diff --git a/be/src/common/config.cpp b/be/src/common/config.cpp index 75495dcb1a2106..474f74433b501e 100644 --- a/be/src/common/config.cpp +++ b/be/src/common/config.cpp @@ -524,10 +524,10 @@ DEFINE_mDouble(compaction_promotion_ratio, "0.05"); DEFINE_mInt64(compaction_promotion_min_size_mbytes, "128"); // When output rowset of cumulative compaction total version count (end_version - start_version) -// exceed this config count, the rowset will be moved to base compaction -// NOTE: this config will work for unique key merge-on-write table only, to reduce version count -// related cost on delete bitmap more effectively. -DEFINE_mInt64(compaction_promotion_version_count, "1000"); +// exceed this config count, the rowset will be moved to base compaction. +// NOTE: this config only works for unique key merge-on-write tables. The default maximum value +// disables version-count-based promotion while retaining the option to enable it when needed. +DEFINE_mInt64(compaction_promotion_version_count, "9223372036854775807"); // The lower bound size to do cumulative compaction. When total disk size of candidate rowsets is less than // this size, size_based policy may not do to cumulative compaction. The unit is m byte. diff --git a/be/src/common/config.h b/be/src/common/config.h index b9e33288396033..1c93d4a4f39ee3 100644 --- a/be/src/common/config.h +++ b/be/src/common/config.h @@ -614,9 +614,9 @@ DECLARE_mDouble(compaction_promotion_ratio); DECLARE_mInt64(compaction_promotion_min_size_mbytes); // When output rowset of cumulative compaction total version count (end_version - start_version) -// exceed this config count, the rowset will be moved to base compaction -// NOTE: this config will work for unique key merge-on-write table only, to reduce version count -// related cost on delete bitmap more effectively. +// exceed this config count, the rowset will be moved to base compaction. +// NOTE: this config only works for unique key merge-on-write tables. The default maximum value +// disables version-count-based promotion while retaining the option to enable it when needed. DECLARE_mInt64(compaction_promotion_version_count); // The lower bound size to do cumulative compaction. When total disk size of candidate rowsets is less than diff --git a/be/test/cloud/cloud_cumulative_compaction_policy_test.cpp b/be/test/cloud/cloud_cumulative_compaction_policy_test.cpp index 35a2598617fca9..0bb4dbfc3bf63d 100644 --- a/be/test/cloud/cloud_cumulative_compaction_policy_test.cpp +++ b/be/test/cloud/cloud_cumulative_compaction_policy_test.cpp @@ -212,6 +212,19 @@ TEST_F(TestCloudSizeBasedCumulativeCompactionPolicy, new_cumulative_point) { EXPECT_EQ(policy.new_cumulative_point(&_tablet, output_rowset, version, 2), 6); } +TEST_F(TestCloudSizeBasedCumulativeCompactionPolicy, + new_cumulative_point_does_not_promote_small_mow_rowset_with_default_version_limit) { + CloudTablet tablet(_engine, _tablet_meta); + tablet._tablet_meta->_enable_unique_key_merge_on_write = true; + tablet._base_size = kGiB; + + CloudSizeBasedCumulativeCompactionPolicy policy; + RowsetSharedPtr output_rowset = create_rowset(Version(2, 1003), 1, false, kMiB); + Version last_delete_version {-1, -1}; + + EXPECT_EQ(2, policy.new_cumulative_point(&tablet, output_rowset, last_delete_version, 2)); +} + TEST_F(TestCloudSizeBasedCumulativeCompactionPolicy, pick_input_rowsets_notready_keeps_latest_versions) { auto base_rowset = create_rowset(Version(0, 1), 1, false, kGiB); diff --git a/be/test/storage/compaction/cumulative_compaction_policy_test.cpp b/be/test/storage/compaction/cumulative_compaction_policy_test.cpp index ad1c536451da7f..a82c52719b1b86 100644 --- a/be/test/storage/compaction/cumulative_compaction_policy_test.cpp +++ b/be/test/storage/compaction/cumulative_compaction_policy_test.cpp @@ -1238,6 +1238,29 @@ TEST_F(TestSizeBasedCumulativeCompactionPolicy, EXPECT_EQ(0, compaction_score); } +TEST_F(TestSizeBasedCumulativeCompactionPolicy, + update_cumulative_point_does_not_promote_small_mow_rowset_with_default_version_limit) { + _tablet_meta->set_enable_unique_key_merge_on_write(true); + TabletSharedPtr tablet( + new Tablet(_engine, _tablet_meta, nullptr, CUMULATIVE_SIZE_BASED_POLICY)); + ASSERT_TRUE(tablet->init().ok()); + tablet->set_cumulative_layer_point(1); + tablet->set_cumulative_promotion_size(64L * kMiB); + + RowsetMetaSharedPtr output_meta(new RowsetMeta()); + init_rs_meta(output_meta, 1, 1002); + output_meta->set_total_disk_size(kMiB); + RowsetSharedPtr output_rowset; + ASSERT_TRUE(RowsetFactory::create_rowset(nullptr, "", output_meta, &output_rowset).ok()); + + std::vector input_rowsets; + Version last_delete_version {-1, -1}; + tablet->_cumulative_compaction_policy->update_cumulative_point( + tablet.get(), input_rowsets, output_rowset, last_delete_version); + + EXPECT_EQ(1, tablet->cumulative_layer_point()); +} + TEST_F(TestSizeBasedCumulativeCompactionPolicy, pick_input_rowsets_large_head_single_overlapping_tail_selected) { std::vector rs_metas;