{"record":{"id":"38e507493127be43","repo":"vitessio/vitess","slug":"errambiguousworkflow","errorCode":"ErrAmbiguousWorkflow","errorMessage":"%w: found %d workflows in keyspace %s with name %s (active_only = %v); this should be impossible","messagePattern":"%w: found (.+?) workflows in keyspace (.+?) with name (.+?) \\(active_only = (.+?)\\); this should be impossible","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vtadmin/cluster/cluster.go","lineNumber":2035,"sourceCode":"\t\t\treturn workflow.Workflow.Name == name\n\t\t},\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tswitch len(workflows.Workflows) {\n\tcase 0:\n\t\tmsg := \"%w for keyspace %s and name %s (active_only = %v)\"\n\t\tif len(workflows.Warnings) > 0 {\n\t\t\treturn nil, fmt.Errorf(msg+\"; warnings: %v\", errors.ErrNoWorkflow, keyspace, name, opts.ActiveOnly, workflows.Warnings)\n\t\t}\n\n\t\treturn nil, fmt.Errorf(msg, errors.ErrNoWorkflow, keyspace, name, opts.ActiveOnly)\n\tcase 1:\n\t\treturn workflows.Workflows[0], nil\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"%w: found %d workflows in keyspace %s with name %s (active_only = %v); this should be impossible\", errors.ErrAmbiguousWorkflow, len(workflows.Workflows), keyspace, name, opts.ActiveOnly)\n\t}\n}\n\n// GetWorkflowsOptions is the set of filtering options for GetWorkflows\n// requests.\ntype GetWorkflowsOptions struct {\n\tActiveOnly      bool\n\tIgnoreKeyspaces sets.Set[string]\n}\n\n// GetWorkflows returns a list of Workflows in this cluster, across the given\n// keyspaces and filtering according to the options passed in.\n//\n// If the list of keyspaces to check is empty, then GetWorkflows will use the\n// result of GetKeyspaces to search all keyspaces in the cluster. In this case,\n// opts.IgnoreKeyspaces is respected.\nfunc (c *Cluster) GetWorkflows(ctx context.Context, keyspaces []string, opts GetWorkflowsOptions) (*vtadminpb.ClusterWorkflows, error) {\n\tspan, ctx := trace.NewSpan(ctx, \"Cluster.GetWorkflows\")","sourceCodeStart":2017,"sourceCodeEnd":2053,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vtadmin/cluster/cluster.go#L2017-L2053","documentation":"GetWorkflow expects a workflow name to identify at most one workflow per keyspace; if the lookup returns more than one match, the result would be ambiguous, so the cluster returns ErrAmbiguousWorkflow wrapped with the count. The 'this should be impossible' wording reflects that workflow names are expected to be unique within a keyspace.","triggerScenarios":"Cluster.GetWorkflow with a name that matches 2+ VReplication workflows in the same keyspace — e.g. leftover/duplicated workflows from interrupted MoveTables/Reshard operations that were not fully cleaned up.","commonSituations":"Orphaned workflows after a failed or aborted MoveTables/Reshard cleanup; manually re-created workflows reusing a name; GTID/failure during vreplication leaving stale shard-level workflow entries.","solutions":["List all workflows with GetWorkflows and inspect duplicates for the name","Delete the stale/duplicate workflow(s) via vtctldclient (DeleteTabletMetadata / Workflow delete) keeping only the intended one","Re-run the query once duplicates are removed"],"exampleFix":"// before\nwf, _ := cluster.GetWorkflow(ctx, \"ks\", \"commerce2customer\", opts)\n// after\nwfs, err := cluster.GetWorkflows(ctx, \"ks\", &cluster.GetWorkflowsOptions{})\n// inspect wfs.Workflows for duplicates, clean up stale ones, then call GetWorkflow","handlingStrategy":"try-catch","validationCode":"wfs, _ := cluster.GetWorkflows(ctx, ks, &cluster.GetWorkflowsOptions{})\nif len(wfs.Workflows) > 1 { /* resolve duplicates before calling GetWorkflow */ }","typeGuard":null,"tryCatchPattern":"wf, err := c.GetWorkflow(ctx, ks, name, opts)\nif errors.Is(err, errors.ErrAmbiguousWorkflow) {\n    // fall back to GetWorkflows and disambiguate by UUID\n}","preventionTips":["Clean up stale workflows after aborted MoveTables/Reshard operations","Prefer addressing workflows by UUID instead of name where possible","Alert on duplicate workflow names within a keyspace"],"tags":["vtadmin","vreplication","ambiguous-workflow"],"backgroundTag":"ambiguous-workflow-name","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}