{"record":{"id":"a59c80eb1add64c4","repo":"vitessio/vitess","slug":"shard-v-v-has-no-source-shard","errorCode":null,"errorMessage":"shard %v/%v has no source shard","messagePattern":"shard (.+?)/(.+?) has no source shard","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/wrangler/split.go","lineNumber":86,"sourceCode":"\t\t// so let's be safe and abort right here.\n\t\tif len(si.SourceShards) > 0 {\n\t\t\treturn fmt.Errorf(\"shard %v/%v already has SourceShards, not overwriting them (full record: %v)\", keyspace, shard, si.Shard)\n\t\t}\n\n\t\tsi.SourceShards = sourceShards\n\t\treturn nil\n\t})\n\treturn err\n}\n\n// WaitForFilteredReplication will wait until the Filtered Replication process has finished.\nfunc (wr *Wrangler) WaitForFilteredReplication(ctx context.Context, keyspace, shard string, maxDelay time.Duration) error {\n\tshardInfo, err := wr.TopoServer().GetShard(ctx, keyspace, shard)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif len(shardInfo.SourceShards) == 0 {\n\t\treturn fmt.Errorf(\"shard %v/%v has no source shard\", keyspace, shard)\n\t}\n\tif !shardInfo.HasPrimary() {\n\t\treturn fmt.Errorf(\"shard %v/%v has no primary\", keyspace, shard)\n\t}\n\talias := shardInfo.PrimaryAlias\n\ttabletInfo, err := wr.TopoServer().GetTablet(ctx, alias)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Always run an explicit healthcheck first to make sure we don't see any outdated values.\n\t// This is especially true for tests and automation where there is no pause of multiple seconds\n\t// between commands and the periodic healthcheck did not run again yet.\n\tif err := wr.TabletManagerClient().RunHealthCheck(ctx, tabletInfo.Tablet); err != nil {\n\t\treturn fmt.Errorf(\"failed to run explicit healthcheck on tablet: %v err: %v\", tabletInfo, err)\n\t}\n\n\tconn, err := tabletconn.GetDialer()(ctx, tabletInfo.Tablet, grpcclient.FailFast(false))","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/wrangler/split.go#L68-L104","documentation":"WaitForFilteredReplication waits until replication lag on a shard's primary (from its SourceShards) drops below a maxDelay. It requires the shard to have at least one SourceShard; a shard with none is not receiving filtered replication, so there is nothing to wait for and the call fails immediately.","triggerScenarios":"Calling WaitForFilteredReplication (via `vtctldclient WaitForFilteredReplication <keyspace/shard> <maxDelay>`) on a shard whose record has an empty SourceShards list.","commonSituations":"Running the wait command before MoveTables/Reshard actually configured the source shard; specifying the source keyspace/shard instead of the destination; automation calling wait after the migration completed and sources were removed.","solutions":["Verify with `vtctldclient GetShard <keyspace>/<shard>` that source_shards is non-empty; if empty, complete the MoveTables/Reshard step that adds it first.","Confirm you are targeting the destination shard, not the source shard.","If migration finished and sources were removed, the wait is unnecessary — skip it."],"exampleFix":"// before\nvtctldclient WaitForFilteredReplication customer/0 30s\n// error: shard customer/0 has no source shard\n// after\nvtctldclient MoveTables --workflow ledger --source commerce customer   # sets up source shard\nvtctldclient WaitForFilteredReplication customer/0 30s","handlingStrategy":"validation","validationCode":"// Before WaitForFilteredReplication, ensure the shard has sources\nshardInfo, _ := vtctldclientGetShard(keyspace, shard)\nif len(shardInfo.SourceShards) == 0 {\n    // run MoveTables/Reshard step that configures filtered replication first\n    fmt.Printf(\"%s/%s has no SourceShards; configure filtered replication first\\n\", keyspace, shard)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only call the wait on destination shards after MoveTables/Reshard set up sources","Confirm you're targeting the destination, not the source shard","In pipelines, assert source_shards non-empty before waiting"],"tags":["filtered-replication","resharding","topo","precondition"],"backgroundTag":"no-source-shards","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}