Repository: risingwavelabs/risingwave
File: src/meta/src/rpc/ddl_controller.rs (Rust)

Code before:
                "no available slots to schedule in resource group \"{}\", \
                 have you allocated any compute nodes within this resource group?",
                resource_group
            );
        };

        if let Some(specified) = specified {
            if specified > max {
                bail_invalid_parameter!(
                    "specified parallelism {} should not exceed max parallelism {}",
                    specified,
                    max,
                );
            }
            if specified > available {
                tracing::warn!(
                    resource_group,
                    specified_parallelism = specified.get(),
                    available_parallelism = available.get(),
                    "specified parallelism exceeds available slots, scheduling with specified value",
                );
            }
            return Ok(specified);
        }

        // Use configured parallelism if no default parallelism is specified.
        let default_parallelism = match default_parallelism {
            DefaultParallelism::Full => available,
            DefaultParallelism::Default(num) => {
                if *num > available {
                    tracing::warn!(
                        resource_group,
                        configured_parallelism = num.get(),
                        available_parallelism = available.get(),
                        "default parallelism exceeds available slots, scheduling with configured value",
                    );
                }
                *num
            }
        };

        if default_parallelism > max {
            tracing::warn!(
                max_parallelism = max.get(),
                resource_group,
                "too many parallelism available, use max parallelism instead",
            );
        }
        Ok(default_parallelism.min(max))
    }


Review comment (suggestion):
This comment is misleading. It states "Use configured parallelism if no default parallelism is specified," but the actual behavior is the opposite: this code path is reached when NO specified parallelism is provided (i.e., `specified` is `None`), and it then uses the default/configured parallelism.

Consider updating to clarify the actual behavior:
```rust
// Use default parallelism when no specific parallelism is provided by the user.
```
```suggestion
        // Use default parallelism when no specific parallelism is provided by the user.
```

Code after:
                "no available slots to schedule in resource group \"{}\", \
                 have you allocated any compute nodes within this resource group?",
                resource_group
            );
        };

        if let Some(specified) = specified {
            if specified > max {
                bail_invalid_parameter!(
                    "specified parallelism {} should not exceed max parallelism {}",
                    specified,
                    max,
                );
            }
            if specified > available {
                tracing::warn!(
                    resource_group,
                    specified_parallelism = specified.get(),
                    available_parallelism = available.get(),
                    "specified parallelism exceeds available slots, scheduling with specified value",
                );
            }
            return Ok(specified);
        }

        // Use default parallelism when no specific parallelism is provided by the user.
        let default_parallelism = match default_parallelism {
            DefaultParallelism::Full => available,
            DefaultParallelism::Default(num) => {
                if *num > available {
                    tracing::warn!(
                        resource_group,
                        configured_parallelism = num.get(),
                        available_parallelism = available.get(),
                        "default parallelism exceeds available slots, scheduling with configured value",
                    );
                }
                *num
            }
        };

        if default_parallelism > max {
            tracing::warn!(
                max_parallelism = max.get(),
                resource_group,
                "default parallelism exceeds max parallelism, capping to max",
            );
        }
        Ok(default_parallelism.min(max))
    }