vitessio/vitess · error
failed to get source keyspace vschema: %v
Error message
failed to get source keyspace vschema: %v
What it means
After resolving the source topo server (internal or external), buildMaterializer fetches the source keyspace's vschema to compare primary vindexes. Failure to fetch this vschema is wrapped with this message and aborts workflow building, since vindex comparison is required for a valid materializer.
Source
Thrown at go/vt/vtctl/workflow/materializer.go:560
}
targetShards = targetShards2
}
if len(targetShards) == 0 {
return fmt.Errorf("no target shards specified for workflow %s ", ms.Workflow)
}
sourceTs := mz.ts
if ms.ExternalCluster != "" { // when the source is an external mysql cluster mounted using the Mount command
externalTopo, err := mz.ts.OpenExternalVitessClusterServer(ctx, ms.ExternalCluster)
if err != nil {
return fmt.Errorf("failed to open external topo: %v", err)
}
sourceTs = externalTopo
}
differentPVs := false
sourceVSchema, err := sourceTs.GetVSchema(ctx, ms.SourceKeyspace)
if err != nil {
return fmt.Errorf("failed to get source keyspace vschema: %v", err)
}
differentPVs = primaryVindexesDiffer(ms, sourceVSchema.Keyspace, vschema.Keyspace)
mz.targetVSchema = targetVSchema
mz.sourceShards = sourceShards
mz.targetShards = targetShards
mz.isPartial = isPartial
mz.primaryVindexesDiffer = differentPVs
return nil
}
// validateEmptyTables checks if all tables are empty across all target shards.
// It queries each shard's primary tablet and if any non-empty table is found,
// returns an error containing a list of non-empty tables.
func (mz *materializer) validateEmptyTables() error {
var mu sync.Mutex
isNonEmptyTable := map[string]bool{}
View on GitHub (pinned to 01a25a7d17)
Solutions
- Confirm the source keyspace exists (`vtctl GetVSchema <keyspace>`) and correct its name if misspelled
- Apply a vschema on the source keyspace with `vtctl ApplyVSchema` if missing
- Check topo server connectivity if the keyspace exists but reads fail
Example fix
// before MoveTables --source-keyspace=commmerce // after MoveTables --source-keyspace=commerce
Defensive patterns
Strategy: validation
Validate before calling
_, err := sourceTs.GetVSchema(ctx, sourceKeyspace)
if err != nil {
return fmt.Errorf("source keyspace %s has no vschema: %w", sourceKeyspace, err)
} Try / catch
if err := createWorkflow(ctx, req); err != nil {
if strings.Contains(err.Error(), "failed to get source keyspace vschema") {
// verify keyspace name and apply a vschema on the source
}
return err
} Prevention
- Ensure every source keyspace has a vschema applied before materialize workflows
- Verify keyspace spelling against GetKeyspaces output
- For external clusters, fetch the vschema through the mount as a pre-check
When it happens
Trigger: sourceTs.GetVSchema(ctx, ms.SourceKeyspace) fails during createWorkflowStreams or WorkflowAddTables — typically because the source keyspace does not exist or the topo read failed.
Common situations: Source keyspace typo; keyspace never created on the source (especially external clusters); topo server connectivity issues; vschema never applied on a freshly created keyspace.
Related errors
- SaveVSchema(%v) = %w
- GetVSchema(keyspace = %s): %w
- EnsureVSchema(%v) failed: %v
- RebuildSrvVSchema(%v) = %w
- table %s not found in vschema for keyspace %s
AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01).
Data as JSON: /api/errors/2abffb4ef6ef98b5.
Report an issue: GitHub.