apache/cassandra · error · RuntimeException
Encountered exception creating schema
Error message
Encountered exception creating schema
What it means
createKeySpaces issues CREATE KEYSPACE/TABLE statements through the CQL driver and wraps any unexpected failure in RuntimeException 'Encountered exception creating schema' with the original exception as cause. AlreadyExistsException is deliberately swallowed (schema already present).
Solutions
- Read the chained 'Caused by' exception for the actual CQL/driver failure
- Verify -schema options, e.g. -schema replication(strategy=NetworkTopologyStrategy,datacenter1=3) is valid for your topology
- Ensure the cluster is up and the stress user has CREATE permission
- If the schema already exists and differs, create it manually first and use -schema keyspace=<name> without creation
Example fix
// before -schema replication(factor=3) on a NetworkTopologyStrategy cluster // after -schema replication(strategy=NetworkTopologyStrategy,dc1=3)
Defensive patterns
Strategy: try-catch
Validate before calling
// pre-check cluster reachability and permissions
session.execute("SELECT cluster_name FROM system.local");
session.execute("LIST PERMISSIONS").all().stream().filter(p -> p.getResource().toString().contains("<keyspace>") && p.getPermission().equals("CREATE")); Try / catch
try { stress.run(); } catch (RuntimeException e) { if (e.getMessage().equals("Encountered exception creating schema")) { Throwable cause = e.getCause(); log("schema creation failed: " + cause); fixSchemaOrRetry(); } else throw e; } Prevention
- Validate -schema replication options against your actual topology/datacenter names
- Ensure the stress user has CREATE permission
- Create the schema manually with cqlsh and let stress reuse it if you need exact DDL
- Confirm nodes are up before launching stress
When it happens
Trigger: Running cassandra-stress with -schema options where the CREATE KEYSPACE or CREATE TABLE fails: replication strategy errors, insufficient permissions, syntax problems from -schema options like replication factor, or the node being unavailable/uninitialized.
Common situations: Typo'd replication strategy in -schema replication, keyspace quota or auth problems, cluster still starting up, driver connection dropped mid-DDL.
Understand the failure class
Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.
Related errors
- ACCESS TO DATACENTERS operations not supported by…
- Aggregate ' ' already exists
- Argument ' ' cannot be frozen; remove frozen<> modifier from
- Can not alter a keyspace to use MetaReplicationStrategy
- Cannot add a column ' ' of type , incompatible with…
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/4826a13e1cea5933.
Report an issue: GitHub.
Appendix: source
Thrown at tools/stress/src/org/apache/cassandra/stress/settings/SettingsSchema.java:89
try
{
//Keyspace
client.execute(createKeyspaceStatementCQL3(), org.apache.cassandra.db.ConsistencyLevel.LOCAL_ONE);
//Add standard1 and counter1
client.execute(createStandard1StatementCQL3(settings), org.apache.cassandra.db.ConsistencyLevel.LOCAL_ONE);
client.execute(createCounter1StatementCQL3(settings), org.apache.cassandra.db.ConsistencyLevel.LOCAL_ONE);
System.out.println(String.format("Created keyspaces. Sleeping %ss for propagation.", settings.node.nodes.size()));
Thread.sleep(settings.node.nodes.size() * 1000L); // seconds
}
catch (AlreadyExistsException e)
{
//Ok.
}
catch (Exception e)
{
throw new RuntimeException("Encountered exception creating schema", e);
}
}
String createKeyspaceStatementCQL3()
{
StringBuilder b = new StringBuilder();
//Create Keyspace
b.append("CREATE KEYSPACE IF NOT EXISTS \"")
.append(keyspace)
.append("\" WITH replication = {'class': '")
.append(replicationStrategy)
.append("'");
if (replicationStrategyOptions.isEmpty())
{
b.append(", 'replication_factor': '1'}");
}View on GitHub (pinned to 88fd0f6a0e)