apache/cassandra · error · IllegalArgumentException
Invalid data rate: ${megabitsPerSecond} megabits per second;
Error message
Invalid data rate: ${megabitsPerSecond} megabits per second; stream_throughput_outbound and inter_dc_stream_throughput_outbound should be between 0 and ${Integer.MAX_VALUE-1} in megabits per second What it means
LongBytesPerSecondBound.megabitsPerSecondInBytesPerSecond converts legacy megabit-based stream throughput settings into bytes per second. If the supplied megabits-per-second value is >= Integer.MAX_VALUE, it throws this IllegalArgumentException naming the valid range for stream_throughput_outbound and inter_dc_stream_throughput_outbound.
Source
Thrown at src/java/org/apache/cassandra/config/DataRateSpec.java:269
*
* @param bytesPerSecond where bytesPerSecond shouldn't be bigger than Long.MAX_VALUE
*/
public LongBytesPerSecondBound(long bytesPerSecond)
{
this(bytesPerSecond, BYTES_PER_SECOND);
}
// this one should be used only for backward compatibility for stream_throughput_outbound and inter_dc_stream_throughput_outbound
// which were in megabits per second in 4.0. Do not start using it for any new properties
/** @deprecated See CASSANDRA-17225 */
@Deprecated(since = "4.1")
public static LongBytesPerSecondBound megabitsPerSecondInBytesPerSecond(long megabitsPerSecond)
{
final long BYTES_PER_MEGABIT = 125_000;
long bytesPerSecond = megabitsPerSecond * BYTES_PER_MEGABIT;
if (megabitsPerSecond >= Integer.MAX_VALUE)
throw new IllegalArgumentException("Invalid data rate: " + megabitsPerSecond + " megabits per second; " +
"stream_throughput_outbound and inter_dc_stream_throughput_outbound" +
" should be between 0 and " + (Integer.MAX_VALUE - 1) + " in megabits per second");
return new LongBytesPerSecondBound(bytesPerSecond, BYTES_PER_SECOND);
}
}
public enum DataRateUnit
{
BYTES_PER_SECOND("B/s")
{
public double toBytesPerSecond(double d)
{
return d;
}
public double toKibibytesPerSecond(double d)
{View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Set the megabits-per-second value below Integer.MAX_VALUE (practically far lower, e.g. 400 Mbps)
- Prefer modern unit-based config values (e.g. 200MiB/s) instead of legacy megabit numbers
- Fix bit-to-byte conversion factors upstream so values stay in a sane range
- Clamp the value before calling the converter if legacy inputs cannot be trusted
Example fix
// before LongBytesPerSecondBound b = DataRateSpec.LongBytesPerSecondBound.megabitsPerSecondInBytesPerSecond(cfg.megabits); // after long megabits = Math.min(cfg.megabits, Integer.MAX_VALUE - 1L); LongBytesPerSecondBound b = DataRateSpec.LongBytesPerSecondBound.megabitsPerSecondInBytesPerSecond(megabits);
Defensive patterns
Strategy: validation
Validate before calling
if (megabitsPerSecond < 0 || megabitsPerSecond >= Integer.MAX_VALUE)
throw new IllegalArgumentException("megabits must be in [0, " + (Integer.MAX_VALUE - 1) + "]"); Try / catch
try {
bound = DataRateSpec.LongBytesPerSecondBound.megabitsPerSecondInBytesPerSecond(mbps);
} catch (IllegalArgumentException e) {
logger.error("Legacy stream throughput out of range: " + mbps, e);
bound = DataRateSpec.LongBytesPerSecondBound.megabitsPerSecondInBytesPerSecond(DEFAULT_MBPS);
} Prevention
- Keep legacy megabit values well below Integer.MAX_VALUE (e.g. <= 1024)
- Prefer modern unit-based config values over legacy megabit settings
- Check conversion factors when moving between bits and bytes
When it happens
Trigger: Calling megabitsPerSecondInBytesPerSecond with a value >= 2147483647, or setting legacy config values that deserialize through this path with such magnitudes.
Common situations: Migrating very old cassandra.yaml files that predate rate units; configs with absurd sentinel values like 999999999; code converting from bits/s and losing track of scale.
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
- Invalid data rate: ${value}. It shouldn't be more than ${max
- Invalid data rate: value must be non-negative
- Invalid data rate: %s %s. It shouldn't be more than %d in %s
- Config contains both old and new keys for the same configura
- %s %s must be between 0 and 1
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/7369dc6f3241d820.
Report an issue: GitHub.