vitessio/vitess · error
CreateKeyspace(%v) failed: %v
Error message
CreateKeyspace(%v) failed: %v
What it means
vtcombo's CreateKs creates a keyspace in the topo via ts.CreateKeyspace; any topo error is wrapped as 'CreateKeyspace(<name>) failed'. This is the vtctld CreateKeyspace path inside the combo process, so failures reflect topo-level keyspacespace problems.
Source
Thrown at go/vt/vtcombo/tablet_map.go:327
func CreateKs(
ctx context.Context,
env *vtenv.Environment,
ts *topo.Server,
tpb *vttestpb.VTTestTopology,
mysqld mysqlctl.MysqlDaemon,
dbcfgs *dbconfigs.DBConfigs,
schemaDir string,
kpb *vttestpb.Keyspace,
ensureDatabase bool,
uid uint32,
wr *wrangler.Wrangler,
srvTopoCounts *stats.CountersWithSingleLabel,
) (uint32, error) {
keyspace := kpb.Name
// create a regular keyspace
if err := ts.CreateKeyspace(ctx, keyspace, &topodatapb.Keyspace{}); err != nil {
return 0, fmt.Errorf("CreateKeyspace(%v) failed: %v", keyspace, err)
}
// make sure a valid vschema has been loaded
if err := ts.EnsureVSchema(ctx, keyspace); err != nil {
return 0, fmt.Errorf("EnsureVSchema(%v) failed: %v", keyspace, err)
}
// iterate through the shards
for _, spb := range kpb.Shards {
shard := spb.Name
if err := ts.CreateShard(ctx, keyspace, shard); err != nil {
return 0, fmt.Errorf("CreateShard(%v:%v) failed: %v", keyspace, shard, err)
}
for _, cell := range tpb.Cells {
dbname := spb.DbNameOverride
if dbname == "" {
dbname = fmt.Sprintf("vt_%v_%v", keyspace, shard)View on GitHub (pinned to 01a25a7d17)
Solutions
- Check whether the keyspace already exists (vtctldclient GetKeyspace) and skip creation or use a different name.
- Verify topo server health and credentials; retry on transient topo errors.
- If retrying creation, ensure prior partial state is cleaned up (DeleteKeyspace) before re-running CreateKs.
Example fix
// before
CreateKs(ctx, ts, ..., &keyspacepb.Keyspace{Name: "commerce"}) // second call
// after
if _, err := ts.GetKeyspace(ctx, "commerce"); err != nil {
CreateKs(ctx, ts, ..., &keyspacepb.Keyspace{Name: "commerce"})
} Defensive patterns
Strategy: try-catch
Validate before calling
// Go: check existence before creating
if _, err := ts.GetKeyspace(ctx, keyspace); err == nil {
return 0, nil // already exists; skip creation
} Try / catch
if _, err := CreateKs(...); err != nil {
if strings.Contains(err.Error(), "CreateKeyspace") && topo.IsTopoException(err) /* e.g. node exists */ {
// keyspace already exists; treat as success or clean up first
}
} Prevention
- Make keyspace creation idempotent: check-then-create or tolerate already-exists errors.
- Serialize keyspace creation across processes to avoid races.
- Verify topo health before batch keyspace setup scripts.
When it happens
Trigger: Calling CreateKs (from InitTabletMap or vtctld gRPC handler) when ts.CreateKeyspace errors: keyspace already exists (duplicate create), topo unavailable, or write permission/serialization error.
Common situations: Re-running an init script that creates an existing keyspace; etcd/zk timeouts; race between two components creating the same keyspace concurrently.
Related errors
- EnsureVSchema(%v) failed: %v
- database not found
- no shards found in keyspace
- keyspace not found
- unable to get shards for keyspace: %s, error: %v
AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01).
Data as JSON: /api/errors/78d772351eecc8d0.
Report an issue: GitHub.