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

  1. Set the megabits-per-second value below Integer.MAX_VALUE (practically far lower, e.g. 400 Mbps)
  2. Prefer modern unit-based config values (e.g. 200MiB/s) instead of legacy megabit numbers
  3. Fix bit-to-byte conversion factors upstream so values stay in a sane range
  4. 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

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


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/7369dc6f3241d820. Report an issue: GitHub.