Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ctl): support mutable compression_algorithm #17026

Merged
merged 1 commit into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions proto/hummock.proto
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,11 @@ message RiseCtlListCompactionGroupResponse {
}

message RiseCtlUpdateCompactionConfigRequest {
message CompressionAlgorithm {
uint32 level = 1;
string compression_algorithm = 2;
}

message MutableConfig {
oneof mutable_config {
uint64 max_bytes_for_level_base = 1;
Expand All @@ -688,6 +693,7 @@ message RiseCtlUpdateCompactionConfigRequest {
uint64 level0_max_compact_file_number = 14;
bool enable_emergency_picker = 15;
uint32 tombstone_reclaim_ratio = 16;
CompressionAlgorithm compression_algorithm = 17;
}
}
repeated uint64 compaction_group_ids = 1;
Expand Down
5 changes: 5 additions & 0 deletions src/ctl/src/cmd_impl/hummock/compaction_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use risingwave_hummock_sdk::compaction_group::StateTableId;
use risingwave_hummock_sdk::{CompactionGroupId, HummockContextId};
use risingwave_pb::hummock::compact_task::TaskStatus;
use risingwave_pb::hummock::rise_ctl_update_compaction_config_request::mutable_config::MutableConfig;
use risingwave_pb::hummock::rise_ctl_update_compaction_config_request::CompressionAlgorithm;

use crate::CtlContext;

Expand Down Expand Up @@ -63,6 +64,7 @@ pub fn build_compaction_config_vec(
level0_overlapping_sub_level_compact_level_count: Option<u32>,
enable_emergency_picker: Option<bool>,
tombstone_reclaim_ratio: Option<u32>,
compress_algorithm: Option<CompressionAlgorithm>,
) -> Vec<MutableConfig> {
let mut configs = vec![];
if let Some(c) = max_bytes_for_level_base {
Expand Down Expand Up @@ -110,6 +112,9 @@ pub fn build_compaction_config_vec(
if let Some(c) = tombstone_reclaim_ratio {
configs.push(MutableConfig::TombstoneReclaimRatio(c))
}
if let Some(c) = compress_algorithm {
configs.push(MutableConfig::CompressionAlgorithm(c))
}

configs
}
Expand Down
16 changes: 16 additions & 0 deletions src/ctl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use cmd_impl::hummock::SstDumpArgs;
use itertools::Itertools;
use risingwave_hummock_sdk::HummockEpoch;
use risingwave_meta::backup_restore::RestoreOpts;
use risingwave_pb::hummock::rise_ctl_update_compaction_config_request::CompressionAlgorithm;
use risingwave_pb::meta::update_worker_node_schedulability_request::Schedulability;
use thiserror_ext::AsReport;

Expand Down Expand Up @@ -254,6 +255,10 @@ enum HummockCommands {
enable_emergency_picker: Option<bool>,
#[clap(long)]
tombstone_reclaim_ratio: Option<u32>,
#[clap(long)]
compression_level: Option<u32>,
#[clap(long)]
compression_algorithm: Option<String>,
},
/// Split given compaction group into two. Moves the given tables to the new group.
SplitCompactionGroup {
Expand Down Expand Up @@ -683,6 +688,8 @@ async fn start_impl(opts: CliOpts, context: &CtlContext) -> Result<()> {
level0_overlapping_sub_level_compact_level_count,
enable_emergency_picker,
tombstone_reclaim_ratio,
compression_level,
compression_algorithm,
}) => {
cmd_impl::hummock::update_compaction_config(
context,
Expand All @@ -703,6 +710,15 @@ async fn start_impl(opts: CliOpts, context: &CtlContext) -> Result<()> {
level0_overlapping_sub_level_compact_level_count,
enable_emergency_picker,
tombstone_reclaim_ratio,
if let Some(level) = compression_level {
assert!(compression_algorithm.is_some());
Some(CompressionAlgorithm {
level,
compression_algorithm: compression_algorithm.unwrap(),
})
} else {
None
},
),
)
.await?
Expand Down
5 changes: 5 additions & 0 deletions src/meta/src/hummock/manager/compaction_group_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,11 @@ fn update_compaction_config(target: &mut CompactionConfig, items: &[MutableConfi
MutableConfig::TombstoneReclaimRatio(c) => {
target.tombstone_reclaim_ratio = *c;
}

MutableConfig::CompressionAlgorithm(c) => {
target.compression_algorithm[c.get_level() as usize]
.clone_from(&c.compression_algorithm);
}
}
}
}
Expand Down
Loading