{"record":{"id":"603b9e3b3d9c6d07","repo":"vitessio/vitess","slug":"a-conflicting-vindex-named-s-already-exists-in-th","errorCode":null,"errorMessage":"a conflicting vindex named %s already exists in the source vschema","messagePattern":"a conflicting vindex named (.+?) already exists in the source vschema","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/wrangler/materializer.go","lineNumber":626,"sourceCode":"\t}\n\t// If source and target keyspaces are same, Make vschemas point to the same object.\n\tif keyspace == targetKeyspace {\n\t\ttargetVSchema = sourceVSchema\n\t} else {\n\t\ttargetVSchema, err = wr.ts.GetVSchema(ctx, targetKeyspace)\n\t\tif err != nil {\n\t\t\treturn nil, nil, nil, err\n\t\t}\n\t}\n\tif targetVSchema.Vindexes == nil {\n\t\ttargetVSchema.Vindexes = make(map[string]*vschemapb.Vindex)\n\t}\n\tif targetVSchema.Tables == nil {\n\t\ttargetVSchema.Tables = make(map[string]*vschemapb.Table)\n\t}\n\tif existing, ok := sourceVSchema.Vindexes[vindexName]; ok {\n\t\tif !proto.Equal(existing, vindex) {\n\t\t\treturn nil, nil, nil, fmt.Errorf(\"a conflicting vindex named %s already exists in the source vschema\", vindexName)\n\t\t}\n\t}\n\tsourceVSchemaTable = sourceVSchema.Tables[sourceTableName]\n\tif sourceVSchemaTable == nil {\n\t\tif !schema.IsInternalOperationTableName(sourceTableName) {\n\t\t\treturn nil, nil, nil, fmt.Errorf(\"source table %s not found in vschema\", sourceTableName)\n\t\t}\n\t}\n\tfor _, colVindex := range sourceVSchemaTable.ColumnVindexes {\n\t\t// For a conflict, the vindex name and column should match.\n\t\tif colVindex.Name != vindexName {\n\t\t\tcontinue\n\t\t}\n\t\tcolName := colVindex.Column\n\t\tif len(colVindex.Columns) != 0 {\n\t\t\tcolName = colVindex.Columns[0]\n\t\t}\n\t\tif colName == sourceVindexColumns[0] {","sourceCodeStart":608,"sourceCodeEnd":644,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/wrangler/materializer.go#L608-L644","documentation":"During CreateLookupVindex, Vitess validates that the vindex name you are creating does not already exist in the source keyspace's vschema with a different definition. If a vindex with the same name exists but its type/params/owner differ from the one being created (compared via proto.Equal), creation is refused. If it exists with an identical definition, the call proceeds idempotently.","triggerScenarios":"Calling CreateLookupVindex (vtctld `CreateLookupVindex` / `Materialize`) with a vindex whose name already exists in the source keyspace's vschema but was defined with a different type, params (e.g. data_type), or owner.","commonSituations":"Re-running an earlier CreateLookupVindex after editing the vindex JSON spec; two operators creating vindexes with colliding names; leftover vindex from a partially-completed earlier backfill with tweaked settings.","solutions":["Check the existing vindex with `vtctldclient GetVSchema <keyspace>` and either use a new, unique vindex name or delete/rename the conflicting one","If the existing vindex is intentionally identical, re-run with the exact same spec so proto.Equal passes and the call is idempotent","If the old vindex is no longer wanted, remove it and its ColumnVindex entry from the source vschema, then retry"],"exampleFix":"// before (conflicting redefinition)\n{\"name\":\"user_lookup\",\"type\":\"consistent_lookup_unique\",\"owner\":\"users\"} // existing: type lookup, no owner\n// after: pick a fresh name or match the existing definition exactly\n{\"name\":\"user_lookup_v2\",\"type\":\"consistent_lookup_unique\",\"owner\":\"users\"}","handlingStrategy":"validation","validationCode":"vs, _ := ts.GetVSchema(ctx, keyspace)\nif existing, ok := vs.Vindexes[vindexName]; ok && !proto.Equal(existing, vindex) {\n    return fmt.Errorf(\"vindex %s already exists with a different definition\", vindexName)\n}","typeGuard":"func hasConflictingVindex(vs *vschemapb.Keyspace, name string, want *vschemapb.Vindex) bool {\n    existing, ok := vs.Vindexes[name]\n    return ok && !proto.Equal(existing, want)\n}","tryCatchPattern":"if err := wr.CreateLookupVindex(ctx, ks, vindex, tables, cols, owner, opts); err != nil {\n    if strings.Contains(err.Error(), \"conflicting vindex\") {\n        // reconcile vschema or pick a new vindex name\n        return reconcileVindex(err)\n    }\n    return err\n}","preventionTips":["Fetch the current vschema and diff your vindex definition before creating","Use descriptive, unique vindex names (e.g. <table>_<purpose>_lookup)","Treat CreateLookupVindex as idempotent only when the spec matches exactly"],"tags":["vitess","vschema","vindex","conflict"],"backgroundTag":"vschema-name-conflict","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}