{"record":{"id":"2abffb4ef6ef98b5","repo":"vitessio/vitess","slug":"failed-to-get-source-keyspace-vschema-v","errorCode":null,"errorMessage":"failed to get source keyspace vschema: %v","messagePattern":"failed to get source keyspace vschema: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vtctl/workflow/materializer.go","lineNumber":560,"sourceCode":"\t\t}\n\t\ttargetShards = targetShards2\n\t}\n\tif len(targetShards) == 0 {\n\t\treturn fmt.Errorf(\"no target shards specified for workflow %s \", ms.Workflow)\n\t}\n\n\tsourceTs := mz.ts\n\tif ms.ExternalCluster != \"\" { // when the source is an external mysql cluster mounted using the Mount command\n\t\texternalTopo, err := mz.ts.OpenExternalVitessClusterServer(ctx, ms.ExternalCluster)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to open external topo: %v\", err)\n\t\t}\n\t\tsourceTs = externalTopo\n\t}\n\tdifferentPVs := false\n\tsourceVSchema, err := sourceTs.GetVSchema(ctx, ms.SourceKeyspace)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to get source keyspace vschema: %v\", err)\n\t}\n\tdifferentPVs = primaryVindexesDiffer(ms, sourceVSchema.Keyspace, vschema.Keyspace)\n\n\tmz.targetVSchema = targetVSchema\n\tmz.sourceShards = sourceShards\n\tmz.targetShards = targetShards\n\tmz.isPartial = isPartial\n\tmz.primaryVindexesDiffer = differentPVs\n\treturn nil\n}\n\n// validateEmptyTables checks if all tables are empty across all target shards.\n// It queries each shard's primary tablet and if any non-empty table is found,\n// returns an error containing a list of non-empty tables.\nfunc (mz *materializer) validateEmptyTables() error {\n\tvar mu sync.Mutex\n\tisNonEmptyTable := map[string]bool{}\n","sourceCodeStart":542,"sourceCodeEnd":578,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vtctl/workflow/materializer.go#L542-L578","documentation":"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.","triggerScenarios":"sourceTs.GetVSchema(ctx, ms.SourceKeyspace) fails during createWorkflowStreams or WorkflowAddTables — typically because the source keyspace does not exist or the topo read failed.","commonSituations":"Source keyspace typo; keyspace never created on the source (especially external clusters); topo server connectivity issues; vschema never applied on a freshly created keyspace.","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"],"exampleFix":"// before\nMoveTables --source-keyspace=commmerce\n// after\nMoveTables --source-keyspace=commerce","handlingStrategy":"validation","validationCode":"_, err := sourceTs.GetVSchema(ctx, sourceKeyspace)\nif err != nil {\n    return fmt.Errorf(\"source keyspace %s has no vschema: %w\", sourceKeyspace, err)\n}","typeGuard":null,"tryCatchPattern":"if err := createWorkflow(ctx, req); err != nil {\n    if strings.Contains(err.Error(), \"failed to get source keyspace vschema\") {\n        // verify keyspace name and apply a vschema on the source\n    }\n    return err\n}","preventionTips":["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"],"tags":["vitess","workflow","vschema","topology","keyspace"],"backgroundTag":"vschema-fetch-failed","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}