{"record":{"id":"d78c7edd17573c4a","repo":"vitessio/vitess","slug":"cannot-rebuild-v-v","errorCode":null,"errorMessage":"cannot rebuild %v: %v","messagePattern":"cannot rebuild (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vtcombo/tablet_map.go","lineNumber":428,"sourceCode":"\t\t\tif err != nil {\n\t\t\t\treturn 0, fmt.Errorf(\"BuildKeyspace(%v) failed: %v\", keyspace, err)\n\t\t\t}\n\t\t\tksvs := &topo.KeyspaceVSchemaInfo{\n\t\t\t\tName:     keyspace,\n\t\t\t\tKeyspace: formal,\n\t\t\t}\n\t\t\tif err := ts.SaveVSchema(ctx, ksvs); err != nil {\n\t\t\t\treturn 0, fmt.Errorf(\"SaveVSchema(%v) failed: %v\", keyspace, err)\n\t\t\t}\n\t\t} else {\n\t\t\tlog.Info(fmt.Sprintf(\"File %v doesn't exist, skipping vschema for keyspace %v\", f, keyspace))\n\t\t}\n\t}\n\n\t// Rebuild the SrvKeyspace object, so we can support\n\t// range-based sharding queries, and export the redirects.\n\tif err := topotools.RebuildKeyspace(ctx, wr.Logger(), wr.TopoServer(), keyspace, nil, false); err != nil {\n\t\treturn 0, fmt.Errorf(\"cannot rebuild %v: %v\", keyspace, err)\n\t}\n\treturn uid, nil\n}\n\n//\n// TabletConn implementation\n//\n\n// dialer is our tabletconn.Dialer\nfunc dialer(ctx context.Context, tablet *topodatapb.Tablet, failFast grpcclient.FailFast) (queryservice.QueryService, error) {\n\tt, ok := tabletMap[tablet.Alias.Uid]\n\tif !ok {\n\t\treturn nil, vterrors.New(vtrpcpb.Code_UNAVAILABLE, \"connection refused\")\n\t}\n\n\treturn &internalTabletConn{\n\t\ttablet:     t,\n\t\ttopoTablet: tablet,","sourceCodeStart":410,"sourceCodeEnd":446,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vtcombo/tablet_map.go#L410-L446","documentation":"After creating tablets and the vschema, CreateKs calls topotools.RebuildKeyspace to regenerate the serving SrvKeyspace object in the topo server. This error means that rebuild failed — typically the topo update failed or no tablets were available to derive serving graph data.","triggerScenarios":"CreateKs completing tablet creation but failing RebuildKeyspace: topo server write failure, keyspace/cell missing from topo, inconsistent tablet records (e.g. primary tablet creation failed earlier), or context cancellation during rebuild.","commonSituations":"Partial InitTabletMap failure leaving tablets half-registered; etcd/zk outage during rebuild; concurrent operations rebuilding the same keyspace; vtcombo shutdown mid-init.","solutions":["Inspect the wrapped error for the underlying topo failure and address it (connectivity, permissions).","Re-run vtctldclient RebuildKeyspaceGraph for the affected keyspace/cells once topo is healthy.","Verify tablets were created correctly (list them in topo) — re-run InitTabletMap if partial.","Ensure the primary tablet creation step succeeded; a missing primary can break serving expectations.","Restart vtcombo init in a clean state if topo data is inconsistent."],"exampleFix":"// manual recovery after failure\nvtctldclient RebuildKeyspaceGraph --cells=cell1 commerce","handlingStrategy":"retry","validationCode":"// ensure the keyspace and tablets exist in topo before rebuild\nif _, err := ts.GetKeyspace(ctx, keyspace); err != nil {\n\treturn fmt.Errorf(\"keyspace missing from topo: %w\", err)\n}\ntablets, err := ts.GetTabletsByCell(ctx, cell, nil)\nif err != nil || len(tablets) == 0 {\n\treturn fmt.Errorf(\"no tablets available for rebuild in cell %s\", cell)\n}","typeGuard":null,"tryCatchPattern":"err := CreateKs(...)\nif err != nil && strings.Contains(err.Error(), \"cannot rebuild\") {\n\t// manual or automatic recovery\n\t_ = vtctldclient.Run(\"RebuildKeyspaceGraph\", \"--cells=\"+cell, keyspace)\n}","preventionTips":["Confirm earlier CreateKs steps (tablet creation, primary election) succeeded before rebuilding","Check topo server health on rebuild failures","Use RebuildKeyspaceGraph manually to recover from partial failures","Avoid concurrent init of the same keyspace"],"tags":["topo","srvkeyspace","rebuild"],"backgroundTag":"srvkeyspace-rebuild-failed","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}