apache/cassandra · error · IllegalArgumentException

Provided datacenter '%s' is not a valid datacenter, availabl

Error message

Provided datacenter '%s' is not a valid datacenter, available datacenters are: %s

What it means

rebuild checks the supplied sourceDc against the datacenters known to cluster metadata (ClusterMetadata.current().directory.knownDatacenters()) and rejects unknown names, listing the valid alternatives.

Source

Thrown at src/java/org/apache/cassandra/service/Rebuild.java:90

        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,
                        tokens == null ? "(All tokens)" : tokens);

            StorageService.instance.repairPaxosForTopologyChange("rebuild");
            ClusterMetadata metadata = ClusterMetadata.current();

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Run `nodetool describecluster` or check the error message's list and use an exact datacenter name
  2. Correct the DC name casing/spelling to match the cluster metadata
  3. Ensure the target DC's nodes are joined and visible in gossip/cluster metadata before rebuilding

Example fix

// before
nodetool rebuild -- Us-East
// after
nodetool rebuild -- us-east
Defensive patterns

Strategy: validation

Validate before calling

Set<String> known = ClusterMetadata.current().directory.knownDatacenters();
if (!known.contains(sourceDc))
    throw new IllegalArgumentException("unknown DC " + sourceDc + "; valid: " + known);

Try / catch

try { rebuild(sourceDc, ...); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith("Provided datacenter")) rebuild(correctDcFrom(e.getMessage()), ...); else throw e; }

Prevention

When it happens

Trigger: rebuild(sourceDc=<name>, ...) where <name> is not in the set of known datacenters.

Common situations: Typo in DC name (`us-east` vs `us_east`); DC renamed or decommissioned; running rebuild before the new DC is fully registered; case mismatch in DC names.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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