apache/cassandra · error · IllegalArgumentException

Randomizer already specified, cannot re-specify

Error message

Randomizer already specified, cannot re-specify: ${value}

What it means

The 'rnd=<randomizer>' modifier sets the wait randomizer, but it can only be specified once. If a randomizer was already supplied (via the parse overload's randomizer parameter or an earlier rnd modifier), RetryStrategy.parse() throws rather than silently overriding it.

Solutions

  1. Remove one of the two rnd specifications so only one remains
  2. If you must supply the randomizer programmatically, strip the ',rnd=...' clause from the spec string
  3. If two rnd clauses exist in the spec, delete the redundant one

Example fix

// before
RetryStrategy.parse("100ms..1s,rnd=exp(2),rnd=uniform", latencies, randomizer);
// after
RetryStrategy.parse("100ms..1s,rnd=exp(2)", latencies); // single source of randomizer
Defensive patterns

Strategy: validation

Validate before calling

static String stripRndModifier(String spec) {
    return spec.replaceAll(",rnd=[^,]+", "");
}
// pass randomizer programmatically OR via spec, never both
RetryStrategy.parse(stripRndModifier(spec), latencies, suppliedRandomizer);

Try / catch

try {
    RetryStrategy strategy = RetryStrategy.parse(spec, latencies, randomizer);
} catch (IllegalArgumentException e) {
    if (e.getMessage().startsWith("Randomizer already specified")) {
        return RetryStrategy.parse(spec.replaceAll(",rnd=[^,]+$", ""), latencies, randomizer);
    }
    throw e;
}

Prevention

When it happens

Trigger: RetryStrategy.parse(spec, latencies, existingRandomizer) where spec also contains ',rnd=...' — or a spec containing two rnd modifiers, e.g. "100ms..1s,rnd=exp(2),rnd=uniform".

Common situations: Merging config fragments that each carry an rnd modifier; programmatically passing a WaitRandomizer while also keeping an rnd clause from a serialized spec string.

Understand the failure class

Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.

Related errors


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

Appendix: source

Thrown at src/java/org/apache/cassandra/service/RetryStrategy.java:293

                    throw new IllegalArgumentException("Invalid modifier specification: '" + spec.substring(next, end) + "'; expecting '=' for value assignment");
                String key = spec.substring(next + 1, mid).trim();
                String value = spec.substring(mid + 1, end).trim();
                switch (key)
                {
                    default: throw new IllegalArgumentException("Invalid modifier specification: unrecognised property '" + key + '\'');
                    case "retries":
                        retries = Integer.parseInt(value);
                        if (retries < 0)
                            throw new IllegalArgumentException("retries must be non-negative (retries=" + value + " supplied)");
                        break;
                    case "attempts":
                        retries = Integer.parseInt(value);
                        if (retries < 0)
                            throw new IllegalArgumentException("Must permit at least one attempt (attempts=" + value + " supplied)");
                        break;
                    case "rnd":
                        if (randomizer != null)
                            throw new IllegalArgumentException("Randomizer already specified, cannot re-specify: " + value);
                        randomizer = parseWaitRandomizer(value);
                        break;
                }
                end = next;
            }
            if (end != spec.length())
                spec = spec.substring(0, end);
        }

        Matcher m = PARSE.matcher(spec);
        if (!m.matches())
            throw new IllegalArgumentException("Invalid specification: '" + spec + "'; does not match " + PARSE);

        long minMin = parseInMicros(m.group("minmin"), 0);
        long maxMax = parseInMicros(m.group("maxmax"), Long.MAX_VALUE);
        Wait max = TimeoutStrategy.parseWait(m.group("max"), latencies);
        String minSpec = m.group("min");
        Wait min = minSpec == null ? null : TimeoutStrategy.parseWait(minSpec, latencies);

View on GitHub (pinned to 88fd0f6a0e)