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 (possibly external) source topo, buildMaterializer fetches the source keyspace's VSchema to compare primary vindex definitions. Any topo or storage failure retrieving that vschema is wrapped with this message.

Source

Thrown at go/vt/wrangler/materializer.go:1116

		}
		targetShards = targetShards2
	}
	if len(targetShards) == 0 {
		return nil, fmt.Errorf("no target shards specified for workflow %s ", ms.Workflow)
	}

	sourceTs := wr.ts
	if ms.ExternalCluster != "" { // when the source is an external mysql cluster mounted using the Mount command
		externalTopo, err := wr.ts.OpenExternalVitessClusterServer(ctx, ms.ExternalCluster)
		if err != nil {
			return nil, fmt.Errorf("failed to open external topo: %v", err)
		}
		sourceTs = externalTopo
	}
	differentPVs := false
	sourceVSchema, err := sourceTs.GetVSchema(ctx, ms.SourceKeyspace)
	if err != nil {
		return nil, fmt.Errorf("failed to get source keyspace vschema: %v", err)
	}
	differentPVs = primaryVindexesDiffer(ms, sourceVSchema.Keyspace, vschema.Keyspace)

	return &materializer{
		wr:                    wr,
		ms:                    ms,
		targetVSchema:         targetVSchema,
		sourceShards:          sourceShards,
		targetShards:          targetShards,
		isPartial:             isPartial,
		primaryVindexesDiffer: differentPVs,
	}, nil
}

func (mz *materializer) getSourceTableDDLs(ctx context.Context) (map[string]string, error) {
	sourceDDLs := make(map[string]string)
	allTables := []string{"/.*/"}

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Verify the source keyspace name and that a vschema exists there (GetVSchema via the right topo).
  2. Check connectivity/health of the source (or external) topo server.
  3. For external clusters, re-mount and re-fetch to rule out stale topo config, then retry the workflow.

Example fix

// before
vtctldclient MoveTables --source commerc --target customer ...  // typo
// after
vtctldclient MoveTables --source commerce --target customer ...
Defensive patterns

Strategy: validation

Validate before calling

_, err := sourceTs.GetVSchema(ctx, sourceKeyspace)
if err != nil {
  return fmt.Errorf("cannot read vschema for source keyspace %s: %w", sourceKeyspace, err)
}

Try / catch

sourceVSchema, err := sourceTs.GetVSchema(ctx, ms.SourceKeyspace)
if err != nil {
  // distinguish topo-unreachable vs keyspace-not-found and act accordingly
}

Prevention

When it happens

Trigger: sourceTs.GetVSchema(ctx, ms.SourceKeyspace) fails — source keyspace does not exist in the (external) topo, topo storage error, or connection failure to the source topo.

Common situations: Wrong source keyspace name (especially on an external mounted cluster); external cluster's topo unreachable mid-command; keyspace deleted between mount and workflow creation.

Related errors


AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01). Data as JSON: /api/errors/eedd1d57c595e194. Report an issue: GitHub.