apache/cassandra · error · IllegalArgumentException
Invalid latency modifier specification
Error message
Invalid latency modifier specification: {spec}. Expect constant factor as base for exponent. What it means
Thrown by TimeoutStrategy.parseLatencyModifier when a latency modifier clause in a timeout specification begins with a modifier kind that is neither null nor a '*' factor; only constant factors (base for exponent) are accepted at this position.
Solutions
- Use a plain numeric constant (e.g. '2') or a '*'-prefixed factor (e.g. '*2') for the modifier.
- Move the '^' exponent syntax to the attempts-modifier position where it is accepted.
- Check the spec against the PARSE regex pattern documented in TimeoutStrategy.
Example fix
// before String spec = "fixed*^2"; // invalid: '^' where a factor is expected // after String spec = "fixed*2"; // or use '...^2' in the attempts-modifier position
Defensive patterns
Strategy: validation
Validate before calling
if (spec != null && spec.matches(".*[^*\d.]\^?.*")) { /* validate against PARSE regex before passing */ }
// simpler: reject '^' at the modifier position
java.util.regex.Pattern p = java.util.regex.Pattern.compile(".*\\*?\\d+(\\.\\d+)?$"); Try / catch
try { TimeoutStrategy.parse(spec, latencies); }
catch (IllegalArgumentException e) { if (e.getMessage().contains("Invalid latency modifier")) { /* correct modifier syntax */ } throw e; } Prevention
- Use plain numbers or '*' factors at the modifier position
- Reserve '^' for the attempts-modifier position only
- Test spec strings in a staging config first
When it happens
Trigger: Passing a timeout/latency spec string whose modifier segment uses an unsupported prefix, e.g. '^' alone or other characters, where a plain numeric factor or '*' factor is expected.
Common situations: Hand-editing cassandra timeout config strings (e.g. read/request timeout expressions) with invalid modifier syntax; confusing '^' (attempts exponent) with the base factor position.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- does not match
- Invalid specification
- does not match
- Unrecognised attempt modifier
- is not a parsable long (base10) for
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/650ab6aa6d00ea13.
Report an issue: GitHub.
Appendix: source
Thrown at src/java/org/apache/cassandra/service/TimeoutStrategy.java:321
if (perc == null)
return new Constant(parseInMicros(m.group("constbase")));
String rw = m.group("rw");
if (rw == null) rw = "rw";
LatencySource latencies = latenciesFactory.source(rw);
double percentile = parseDouble("0." + perc);
return new Percentile(latencies, percentile);
}
private static @Nullable LatencyModifier parseLatencyModifier(String spec, Matcher m, LatencyModifierFactory modifiers)
{
String mod = m.group("mod");
String modkind = m.group("modkind");
double modifier = 1.0;
if (mod != null) modifier = Double.parseDouble(mod);
else if (modkind == null) return null;
else if (!modkind.startsWith("*"))
throw new IllegalArgumentException("Invalid latency modifier specification: " + spec + ". Expect constant factor as base for exponent.");
if (modkind == null)
return modifiers.multiply(modifier);
if (modkind.startsWith("*"))
return modifiers.multiplyByAttempts(modifier);
else if (modkind.startsWith("^"))
return modifiers.multiplyByAttemptsExp(modifier);
else
throw new IllegalArgumentException("Unrecognised attempt modifier: " + modkind);
}
static long saturatedCast(double v)
{
if (v > Long.MAX_VALUE)
return Long.MAX_VALUE;
return (long) v;
}View on GitHub (pinned to 88fd0f6a0e)