vitessio/vitess · error

RebuildSrvVSchema(%v) = %w

Error message

RebuildSrvVSchema(%v) = %w

What it means

After creating the keyspace (and VSchema for snapshots), CreateKeyspace rebuilds the per-cell serving VSchema so routers learn about the new keyspace. An empty cells slice means rebuild in all known cells; if RebuildSrvVSchema fails for any cell, the error is wrapped as RebuildSrvVSchema(%v) = %w and the RPC returns it.

Source

Thrown at go/vt/vtctl/grpcvtctldserver/server.go:1017

		// so we do NOT call bksvs.CloneVT() here. We instead only
		// clone the vschemapb.Keyspace field for the new snapshot
		// keyspace.
		sksvs := &topo.KeyspaceVSchemaInfo{
			Name:     req.Name,
			Keyspace: bksvs.Keyspace.CloneVT(),
		}
		// SNAPSHOT keyspaces are excluded from global routing.
		sksvs.RequireExplicitRouting = true

		if err = s.ts.SaveVSchema(ctx, sksvs); err != nil {
			return nil, fmt.Errorf("SaveVSchema(%v) = %w", sksvs, err)
		}
	}

	cells := []string{}
	err = s.ts.RebuildSrvVSchema(ctx, cells)
	if err != nil {
		return nil, fmt.Errorf("RebuildSrvVSchema(%v) = %w", cells, err)
	}

	return &vtctldatapb.CreateKeyspaceResponse{
		Keyspace: &vtctldatapb.Keyspace{
			Name:     req.Name,
			Keyspace: ki,
		},
	}, nil
}

// CreateShard is part of the vtctlservicepb.VtctldServer interface.
func (s *VtctldServer) CreateShard(ctx context.Context, req *vtctldatapb.CreateShardRequest) (resp *vtctldatapb.CreateShardResponse, err error) {
	span, ctx := trace.NewSpan(ctx, "VtctldServer.CreateShard")
	defer span.Finish()

	defer panicHandler(&err)

	span.Annotate("keyspace", req.Keyspace)

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Read the wrapped cause to identify which cell failed
  2. Fix topo connectivity or remove the dead cell from the known cells list
  3. Manually run RebuildVSchema (vtctldclient RebuildVSchemaGraph) after correcting the issue
  4. Verify SrvVSchema entries per cell with GetSrvVSchema
Defensive patterns

Strategy: retry

Validate before calling

for _, cell := range cells {
    if _, err := ts.GetSrvVSchema(ctx, cell); err != nil {
        log.Printf("cell %s srv vschema unreadable: %v", cell, err)
    }
}

Try / catch

_, err := client.CreateKeyspace(ctx, req)
if err != nil && strings.Contains(err.Error(), "RebuildSrvVSchema") {
    // inspect which cell failed; fix/remove it and run RebuildVSchemaGraph
}

Prevention

When it happens

Trigger: Any CreateKeyspace call where rebuilding serving vshards fails: topo write errors, a cell unreachable, or an existing corrupt SrvVSchema node in one of the cells.

Common situations: A dead/decommissioned cell still listed in the topo; network partition to one cell's topo backend; permission issues on SrvVSchema paths.

Related errors


AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01). Data as JSON: /api/errors/cbc6814bed11b224. Report an issue: GitHub.