{"record":{"id":"1a091e99e5c95fc5","repo":"vitessio/vitess","slug":"cannot-remove-cell-v-from-shard-v-v-w","errorCode":null,"errorMessage":"cannot remove cell %v from shard %v/%v: %w","messagePattern":"cannot remove cell (.+?) from shard (.+?)/(.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vtctl/grpcvtctldserver/server.go","lineNumber":3624,"sourceCode":"\tdefer span.Finish()\n\n\tdefer panicHandler(&err)\n\n\tspan.Annotate(\"keyspace\", req.Keyspace)\n\tspan.Annotate(\"cell\", req.Cell)\n\tspan.Annotate(\"force\", req.Force)\n\tspan.Annotate(\"recursive\", req.Recursive)\n\n\tshards, err := s.ts.GetShardNames(ctx, req.Keyspace)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Remove all the shards, serially. Stop immediately if any fail.\n\tfor _, shard := range shards {\n\t\tlog.Info(fmt.Sprintf(\"Removing cell %v from shard %v/%v\", req.Cell, req.Keyspace, shard))\n\t\tif err2 := removeShardCell(ctx, s.ts, req.Cell, req.Keyspace, shard, req.Recursive, req.Force); err2 != nil {\n\t\t\terr = fmt.Errorf(\"cannot remove cell %v from shard %v/%v: %w\", req.Cell, req.Keyspace, shard, err2)\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\t// Last, remove the SrvKeyspace object.\n\tlog.Info(fmt.Sprintf(\"Removing cell %v keyspace %v SrvKeyspace object\", req.Cell, req.Keyspace))\n\tif err = s.ts.DeleteSrvKeyspace(ctx, req.Cell, req.Keyspace); err != nil {\n\t\terr = fmt.Errorf(\"cannot delete SrvKeyspace from cell %v for keyspace %v: %w\", req.Cell, req.Keyspace, err)\n\t\treturn nil, err\n\t}\n\n\treturn &vtctldatapb.RemoveKeyspaceCellResponse{}, nil\n}\n\n// RemoveShardCell is part of the vtctlservicepb.VtctldServer interface.\nfunc (s *VtctldServer) RemoveShardCell(ctx context.Context, req *vtctldatapb.RemoveShardCellRequest) (resp *vtctldatapb.RemoveShardCellResponse, err error) {\n\tspan, ctx := trace.NewSpan(ctx, \"VtctldServer.RemoveShardCell\")\n\tdefer span.Finish()","sourceCodeStart":3606,"sourceCodeEnd":3642,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vtctl/grpcvtctldserver/server.go#L3606-L3642","documentation":"When removing a cell from a keyspace, each shard's cell removal (removeShardCell) is attempted serially, stopping at the first failure. This error wraps the per-shard failure (e.g. tablets still serving in that cell without -force) with the cell, keyspace, and shard context.","triggerScenarios":"vtctldclient RemoveKeyspaceCell where removeShardCell fails — serving tablets remain in the cell and Recursive/Force were not set, or topo deletion of the SrvVReverse links failed.","commonSituations":"Trying to decommission a cell that still hosts replicas for the keyspace; forgetting -recursive; a tablet in the cell is unresponsive so its records can't be cleaned.","solutions":["Re-run with `--recursive` (and `--force` if appropriate) so in-cell tablets are handled","Scrap/remove the remaining tablets in that cell first (`GetTablets` filtered by cell)","Verify no serving tablets remain in the cell, then retry RemoveKeyspaceCell","Check topo server health if deletion itself failed"],"exampleFix":"// before\nvtctldclient RemoveKeyspaceCell --keyspace commerce zone2  # tablets remain\n// after\nvtctldclient RemoveKeyspaceCell --keyspace commerce --recursive --force zone2","handlingStrategy":"validation","validationCode":"// ensure no tablets remain in the cell before removal\nfor _, t := range tablets {\n    if t.Keyspace == ks && t.Alias.Cell == cell {\n        return fmt.Errorf(\"tablet %s still in cell %s\", t.Alias, cell)\n    }\n}","typeGuard":null,"tryCatchPattern":"// fall back to recursive/force removal on first failure\nif strings.Contains(err.Error(), \"cannot remove cell\") {\n    return removeKeyspaceCell(ctx, ks, cell, /*recursive*/ true, /*force*/ true)\n}","preventionTips":["Always pass --recursive when draining a cell that hosts tablets","Inventory per-cell tablets before decommissioning cells","Use --force only after confirming no traffic is served from the cell","Drain and scrap tablets cell-by-cell with VTGate pool removal first"],"tags":["vtctld","topology","cell-removal","keyspace"],"backgroundTag":"remove-cell-failed","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}