apache/cassandra · error · ConfigurationException
Invalid dc weighting syntax
Error message
Invalid dc weighting syntax %s, use <dc>:<weight>
What it means
WeightedDc.fromString throws a ConfigurationException when a dcs entry splits on the colon separator into more than two parts, i.e. it is not of the form <dc> or <dc>:<weight>. The message shows the offending entry and the required '<dc>:<weight>' syntax.
Solutions
- Rewrite each entry as either '<dc>' or '<dc>:<weight>' with exactly one colon at most
- Rename the datacenter to avoid colons, or reference it via a colon-free alias
- Validate the list with a regex like ^[^:]+(:\d+)?$ per entry before applying
Example fix
// before 'dcs':'dc1:1:2,dc2' // after 'dcs':'dc1:1,dc2'
Defensive patterns
Strategy: validation
Validate before calling
java.util.regex.Pattern OK = java.util.regex.Pattern.compile("^[^:]+(:\\d+)?$");
for (String entry : dcs.split(",")) {
if (!OK.matcher(entry.trim()).matches())
throw new IllegalArgumentException("entry must be <dc> or <dc>:<weight>: " + entry);
} Try / catch
try { applyFastPathOption(opts); } catch (org.apache.cassandra.exceptions.ConfigurationException e) {
if (e.getMessage().contains("use <dc>:<weight>"))
log.error("Each dcs entry may contain at most one colon separating dc and weight");
} Prevention
- Avoid colon-containing datacenter names; use hyphens
- Format entries strictly as <dc> or <dc>:<int>
- Regex-validate each entry before submitting options
- Do not hand-edit serialized asMap output
When it happens
Trigger: Passing a dcs entry containing multiple colons such as 'dc1:1:2' or a DC name that itself contains a colon (e.g. an IPv6-ish or namespaced name) to the accord parameterized fast_path strategy.
Common situations: Operators pasting composite identifiers with colons; accidental double-colon (e.g. 'dc1::2'); confusion with other weight syntaxes (yaml maps) elsewhere in Cassandra config.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- accord.cache_size option was set incorrectly to
- accord.journal_directory must not be the same as any…
- Cannot change transactional mode to
- dc name must not be empty
- DC weights must be zero or positive
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/8aa86173ae6125d3.
Report an issue: GitHub.
Appendix: source
Thrown at src/java/org/apache/cassandra/service/accord/topology/ParameterizedFastPathStrategy.java:150
int weight = Integer.parseInt(w);
if (weight < 0)
throw cfe("DC weights must be zero or positive");
return weight;
}
static WeightedDc fromString(String s, int idx)
{
s = s.trim();
if (s.isEmpty())
throw cfe("%s entries must not be empty", DCS);
String[] parts = COLON_SEPARATOR.split(s);
if (parts.length == 1)
return new WeightedDc(validateDC(parts[0]), idx, true);
else if (parts.length == 2)
return new WeightedDc(validateDC(parts[0]), validateWeight(parts[1]), false);
else
throw cfe("Invalid dc weighting syntax %s, use <dc>:<weight>", s);
}
}
public final int size;
private final ImmutableMap<String, WeightedDc> dcs;
ParameterizedFastPathStrategy(int size, ImmutableMap<String, WeightedDc> dcs)
{
this.size = size;
this.dcs = dcs;
}
public boolean equals(Object o)
{
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ParameterizedFastPathStrategy that = (ParameterizedFastPathStrategy) o;
return size == that.size && Objects.equals(dcs, that.dcs);View on GitHub (pinned to 88fd0f6a0e)