risingwavelabs/risingwave · error

`compaction.max_snapshots_num` must be greater than 0, got:

Error message

`compaction.max_snapshots_num` must be greater than 0, got: {}

What it means

During Iceberg sink config alteration, `compaction.max_snapshots_num` must be at least 1. A value of 0 or negative would mean compaction triggers on zero snapshots or is nonsensical, so validation rejects it.

Source

Thrown at src/connector/src/sink/iceberg/mod.rs:327

        // Validate compaction interval
        if let Some(compaction_interval) = iceberg_config.compaction_interval_sec {
            if iceberg_config.enable_compaction && compaction_interval == 0 {
                bail!(
                    "`compaction-interval-sec` must be greater than 0 when `enable-compaction` is true"
                );
            }

            tracing::info!(
                "Alter config compaction_interval set to {} seconds",
                compaction_interval
            );
        }

        // Validate max snapshots
        if let Some(max_snapshots) = iceberg_config.max_snapshots_num_before_compaction
            && max_snapshots < 1
        {
            bail!(
                "`compaction.max_snapshots_num` must be greater than 0, got: {}",
                max_snapshots
            );
        }

        // Validate target file size
        if let Some(target_file_size_mb) = iceberg_config.target_file_size_mb
            && target_file_size_mb == 0
        {
            bail!("`compaction.target_file_size_mb` must be greater than 0");
        }

        // Validate parquet max row group rows
        if let Some(max_row_group_rows) = iceberg_config.write_parquet_max_row_group_rows
            && max_row_group_rows == 0
        {
            bail!("`compaction.write_parquet_max_row_group_rows` must be greater than 0");
        }

View on GitHub (pinned to 6469eb736d)

Solutions

  1. Set `compaction.max_snapshots_num` to a positive integer, e.g. `100`.
  2. Remove the property to fall back to the built-in default threshold.
  3. Use `enable-compaction=false` if the intent is to disable snapshot-based compaction entirely.

Example fix

-- before
ALTER SINK s SET ('compaction.max_snapshots_num'='0');
-- after
ALTER SINK s SET ('compaction.max_snapshots_num'='100');
Defensive patterns

Strategy: validation

Validate before calling

fn valid_max_snapshots(cfg: &std::collections::BTreeMap<String, String>) -> Result<(), String> {
    if let Some(s) = cfg.get("compaction.max_snapshots_num") {
        if s.parse::<i64>().unwrap_or(0) < 1 {
            return Err("compaction.max_snapshots_num must be >= 1".into());
        }
    }
    Ok(())
}

Prevention

When it happens

Trigger: `ALTER SINK ... SET` with `compaction.max_snapshots_num = '0'` or a negative number while configuring snapshot-retention-based compaction.

Common situations: Users misreading the option as 'delete all snapshots' and setting 0; arithmetic/templating producing 0; confusion with an infinity/disable sentinel.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


AI-assisted analysis of risingwavelabs/risingwave@6469eb736d (2026-09-11). Data as JSON: /api/errors/db800ffb8a6b67e7. Report an issue: GitHub.