{"record":{"id":"40d8cfa4caca7eff","repo":"vitessio/vitess","slug":"missing-source","errorCode":null,"errorMessage":"missing source","messagePattern":"missing source","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vttablet/tabletmanager/vreplication/controller.go","lineNumber":361,"sourceCode":"\t\t// it's a FAILED_PRECONDITION vterror, OR we cannot identify this as\n\t\t// non-recoverable BUT it has persisted beyond the retry limit\n\t\t// (maxTimeToRetryError). In addition, we cannot restart a workflow\n\t\t// started with AtomicCopy which has _any_ error during copy phase.\n\t\tif (err != nil && vr.WorkflowSubType == int32(binlogdatapb.VReplicationWorkflowSubType_AtomicCopy) && vr.state == binlogdatapb.VReplicationWorkflowState_Copying) ||\n\t\t\tisUnrecoverableError(err) ||\n\t\t\t!ct.lastWorkflowError.ShouldRetry() {\n\t\t\terr = vterrors.Wrapf(err, TerminalErrorIndicator)\n\t\t\tif errSetState := vr.setState(binlogdatapb.VReplicationWorkflowState_Error, err.Error()); errSetState != nil {\n\t\t\t\tlog.Error(fmt.Sprintf(\"INTERNAL: unable to setState() in controller: %v. Could not set error text to: %v.\", errSetState, err))\n\t\t\t\treturn err // yes, err and not errSetState.\n\t\t\t}\n\t\t\tlog.Error(fmt.Sprintf(\"%s going into error state due to %+v\", ct.logPrefix(), err))\n\t\t\treturn nil // this will cause vreplicate to quit the workflow\n\t\t}\n\t\treturn err\n\t}\n\tct.blpStats.ErrorCounts.Add([]string{\"Invalid Source\"}, 1)\n\treturn errors.New(\"missing source\")\n}\n\nfunc (ct *controller) setMessage(dbClient binlogplayer.DBClient, message string) error {\n\tct.blpStats.History.Add(&binlogplayer.StatsHistoryRecord{\n\t\tTime:    time.Now(),\n\t\tMessage: message,\n\t})\n\tquery := fmt.Sprintf(\"update _vt.vreplication set message=%v where id=%v\", encodeString(binlogplayer.MessageTruncate(message)), ct.id)\n\tif _, err := dbClient.ExecuteFetch(query, 1); err != nil {\n\t\treturn fmt.Errorf(\"could not set message: %v: %v\", query, err)\n\t}\n\treturn nil\n}\n\n// pickSourceTablet picks a healthy serving tablet to source for\n// the vreplication stream. If the source is marked as external, it\n// returns nil.\nfunc (ct *controller) pickSourceTablet(ctx context.Context, dbClient binlogplayer.DBClient) (*topodatapb.Tablet, error) {","sourceCodeStart":343,"sourceCodeEnd":379,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vttablet/tabletmanager/vreplication/controller.go#L343-L379","documentation":"The vreplication controller (runBlp) reaches a state where its source tablet/position is unset and returns 'missing source' after incrementing the 'Invalid Source' error counter. runBlp needs a valid source (tablet + binlog position) to start replicating; if the workflow's source record is missing it cannot continue.","triggerScenarios":"Starting/running a vreplication stream whose _vt.vreplication row's source (tablet alias / source keyspace-shard) cannot be resolved, so blpFunc signals the source is invalid.","commonSituations":"Source tablet decommissioned or moved without updating the workflow; pruned/shard-merged workflows with stale source entries; manual edits to _vt.vreplication; failed MoveTables/Reshard source resolution.","solutions":["Re-check the workflow source with vtctl VReplicationExec / Workflow show and confirm the source tablet and keyspace/shard are valid","Recreate or restart the workflow (MoveTables/Reshard create) so the source is re-resolved against the current topo","If the source was intentionally removed, cancel the stale _vt.vreplication row (vtctl Workflow ... cancel/delete)","Check source tablet health/registration in the topo and re-run the workflow"],"exampleFix":"// before\n$ vtctlclient VReplicationExec <tablet> 'show'  // source missing\n// after\n$ vtctlclient MoveTables -workflow=sales -target ks2 create ... // recreate stream with valid source","handlingStrategy":"try-catch","validationCode":"// verify the workflow source resolves before starting\nrows, _ := db.ExecuteFetch(\"select source, pos from _vt.vreplication\", 100)","typeGuard":null,"tryCatchPattern":"if err := runBlp(ctx); err != nil && strings.Contains(err.Error(), \"missing source\") {\n    // recreate/cancel the stale workflow row\n    vtctldclient Workflow --keyspace ks cancel <workflow>\n}","preventionTips":["Cancel stale _vt.vreplication rows after source tablets are decommissioned","Re-create workflows after Reshard/MoveTables source changes","Monitor blpStats ErrorCounts 'Invalid Source' counter"],"tags":["vreplication","source","workflow"],"backgroundTag":"invalid-vreplication-source","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}