chore: add panic at compactor startup for invalid config options (#7141)

* chore: add panic at compactor startup for invalid config options

* chore: apply comments
pull/24376/head
Joe-Blount 2023-03-07 15:02:01 -06:00 committed by GitHub
parent 9e9e689a30
commit 86dd72ef1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 0 deletions

View File

@ -32,6 +32,11 @@ use trace::TraceCollector;
const TOPIC: &str = "iox-shared";
const TRANSITION_SHARD_INDEX: i32 = TRANSITION_SHARD_NUMBER;
// Minimum multiple between max_desired_file_size_bytes and max_input_parquet_bytes_per_partition
// Since max_desired_file_size_bytes is softly enforced, actual file sizes can exceed it, and a
// single compaction job must be able to compact >1 max sized file, so the multiple should be at least 3.
const MIN_COMPACT_SIZE_MULTIPLE: i64 = 3;
pub struct Compactor2ServerType {
compactor: Compactor2,
metric_registry: Arc<Registry>,
@ -172,6 +177,18 @@ pub async fn create_compactor2_server_type(
),
};
if compactor_config.max_desired_file_size_bytes as i64 * MIN_COMPACT_SIZE_MULTIPLE
> compactor_config
.max_input_parquet_bytes_per_partition
.try_into()
.unwrap()
{
panic!("max_input_parquet_bytes_per_partition ({}) must be at least {} times larger than max_desired_file_size_bytes ({})",
compactor_config.max_input_parquet_bytes_per_partition,
MIN_COMPACT_SIZE_MULTIPLE,
compactor_config.max_desired_file_size_bytes);
}
let compactor = Compactor2::start(Config {
shard_id,
metric_registry: Arc::clone(&metric_registry),