apache/cassandra · error · IllegalArgumentException
Cannot set source data center to be local data center, when
Error message
Cannot set source data center to be local data center, when excludeLocalDataCenter flag is set
What it means
rebuild validates that when the --exclude-local-datacenter flag is set, the chosen source DC must not equal the local data center, since excluding local DC nodes leaves no possible sources if the source is the local DC itself.
Source
Thrown at src/java/org/apache/cassandra/service/Rebuild.java:86
@VisibleForTesting
public static void unsafeResetRebuilding()
{
isRebuilding.set(false);
}
public static void rebuild(String sourceDc, String keyspace, String tokens, String specificSources, boolean excludeLocalDatacenterNodes)
{
// check ongoing rebuild
if (!isRebuilding.compareAndSet(false, true))
{
throw new IllegalStateException("Node is still rebuilding. Check nodetool netstats.");
}
if (sourceDc != null)
{
if (sourceDc.equals(DatabaseDescriptor.getLocalDataCenter()) && excludeLocalDatacenterNodes) // fail if source DC is local and --exclude-local-dc is set
throw new IllegalArgumentException("Cannot set source data center to be local data center, when excludeLocalDataCenter flag is set");
Set<String> availableDCs = ClusterMetadata.current().directory.knownDatacenters();
if (!availableDCs.contains(sourceDc))
{
throw new IllegalArgumentException(String.format("Provided datacenter '%s' is not a valid datacenter, available datacenters are: %s",
sourceDc, String.join(",", availableDCs)));
}
}
try
{
// check the arguments
if (keyspace == null && tokens != null)
{
throw new IllegalArgumentException("Cannot specify tokens without keyspace.");
}
logger.info("rebuild from dc: {}, {}, {}", sourceDc == null ? "(any dc)" : sourceDc,
keyspace == null ? "(All keyspaces)" : keyspace,View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Omit the sourceDc argument so rebuild picks a non-local DC automatically
- Pass a source DC different from the local data center
- Remove the --exclude-local-datacenter flag if streaming from the local DC is actually intended
Example fix
// before nodetool rebuild --exlude-local-dc dc1 dc1 // after (source must differ from local DC) nodetool rebuild -- dc2
Defensive patterns
Strategy: validation
Validate before calling
String local = DatabaseDescriptor.getLocalDataCenter();
if (excludeLocalDc && sourceDc != null && sourceDc.equals(local))
throw new IllegalArgumentException("sourceDc must differ from local DC when excludeLocalDatacenterNodes=true"); Try / catch
try { rebuild(sourceDc, ..., true); } catch (IllegalArgumentException e) { if (e.getMessage().contains("excludeLocalDataCenter")) rebuild(null, ...); else throw e; } Prevention
- Never combine --exclude-local-datacenter with an explicit source DC equal to the local DC
- Verify cassandra-rackdc.properties local_dc value matches the DC name you pass
- Prefer omitting sourceDc and letting rebuild pick a remote DC automatically
When it happens
Trigger: Calling rebuild(sourceDc=X, ..., excludeLocalDatacenterNodes=true) where X equals DatabaseDescriptor.getLocalDataCenter().
Common situations: Operator runs `nodetool rebuild --exlude-local-dc` (or -dl) and still passes the local DC as source; copy-pasted runbook command with wrong DC name; misconfigured local data center in cassandra-rackdc.properties so the 'remote' DC name matches local.
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
- Provided datacenter '%s' is not a valid datacenter, availabl
- Invalid data rate: value must be non-negative
- Invalid data storage: %s Accepted units:%s
- Invalid value of entire_sstable_stream_throughput_outbound:
- Invalid value of entire_sstable_inter_dc_stream_throughput_o
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/39a5ca8b18fcce70.
Report an issue: GitHub.