{"record":{"id":"d3f743dd4f149f34","repo":"vitessio/vitess","slug":"error-deleting-shardreplication-object-in-cell-v","errorCode":null,"errorMessage":"error deleting ShardReplication object in cell %v: %w","messagePattern":"error deleting ShardReplication object in cell (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vtctl/grpcvtctldserver/topo.go","lineNumber":314,"sourceCode":"\t\t// We have tablets in the shard in this cell.\n\t\tif recursive {\n\t\t\tlog.Info(fmt.Sprintf(\"Deleting all tablets in cell %v in shard %v/%v\", cell, keyspace, shardName))\n\t\t\tfor _, node := range replication.Nodes {\n\t\t\t\t// We don't care about scrapping or updating the replication\n\t\t\t\t// graph, because we're about to delete the entire replication\n\t\t\t\t// graph.\n\t\t\t\tlog.Info(fmt.Sprintf(\"Deleting tablet %v\", topoproto.TabletAliasString(node.TabletAlias)))\n\t\t\t\tif err := ts.DeleteTablet(ctx, node.TabletAlias); err != nil && !topo.IsErrType(err, topo.NoNode) {\n\t\t\t\t\treturn fmt.Errorf(\"cannot delete tablet %v: %w\", topoproto.TabletAliasString(node.TabletAlias), err)\n\t\t\t\t}\n\t\t\t}\n\t\t} else if len(replication.Nodes) > 0 {\n\t\t\treturn vterrors.Errorf(vtrpc.Code_FAILED_PRECONDITION, \"cell %v has %v possible tablets in replication graph\", cell, len(replication.Nodes))\n\t\t}\n\n\t\t// Remove the empty replication graph.\n\t\tif err := ts.DeleteShardReplication(ctx, cell, keyspace, shardName); err != nil && !topo.IsErrType(err, topo.NoNode) {\n\t\t\treturn fmt.Errorf(\"error deleting ShardReplication object in cell %v: %w\", cell, err)\n\t\t}\n\tcase topo.IsErrType(err, topo.NoNode):\n\t\t// No ShardReplication object. This is the expected path when there are\n\t\t// no tablets in the shard in that cell.\n\t\terr = nil\n\tdefault:\n\t\t// If we can't get the replication object out of the local topo, we\n\t\t// assume the topo server is down in that cell, so we'll only continue\n\t\t// if Force was specified.\n\t\tif !force {\n\t\t\treturn err\n\t\t}\n\n\t\tlog.Warn(fmt.Sprintf(\"Cannot get ShardReplication from cell %v; assuming cell topo server is down and forcing removal\", cell))\n\t}\n\n\t// Finally, update the shard.\n","sourceCodeStart":296,"sourceCodeEnd":332,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vtctl/grpcvtctldserver/topo.go#L296-L332","documentation":"removeShardCell wraps a failure from DeleteShardReplication when clearing the (now-empty) replication graph for the shard in a cell. NoNode is treated as success; any other error aborts cell removal so stale ShardReplication nodes are never left behind silently.","triggerScenarios":"RemoveKeyspaceCell or RemoveShardCell after all tablets were deleted, but ts.DeleteShardReplication(ctx, cell, keyspace, shardName) fails with a topo RPC/ACL/timeout error.","commonSituations":"Topo outage during keyspace teardown; ACL preventing writes to the replication graph path; flaky cell topo (e.g., remote cell connection drop).","solutions":["Verify topo connectivity to the cell and retry RemoveKeyspaceCell/RemoveShardCell; the operation is idempotent (NoNode tolerated)","Check topo ACLs for write access to the ShardReplication path","If persistently stuck, delete the stale ShardReplication node directly via topo tooling (etcdctl/zkCli) with care"],"exampleFix":"// before\nvtctldclient RemoveKeyspaceCell ks c1  # fails deleting ShardReplication\n// after\n# restore topo connectivity, then retry\nvtctldclient RemoveKeyspaceCell ks c1","handlingStrategy":"retry","validationCode":"// Confirm ShardReplication is empty/deletable before removal\nsri, err := ts.GetShardReplication(ctx, cell, ks, shard)\nif err == nil && len(sri.Nodes) > 0 {\n\treturn fmt.Errorf(\"cell %s still has %d replication nodes\", cell, len(sri.Nodes))\n}","typeGuard":null,"tryCatchPattern":"if err := removeKeyspaceCell(ctx, ks, cell); err != nil && strings.Contains(err.Error(), \"ShardReplication\") {\n\t// topo hiccup: retry; NoNode path is already success\n}","preventionTips":["Complete tablet deletion before removing the shard cell","Maintain reliable cell-to-topo connectivity","Treat missing ShardReplication as normal in teardown logic"],"tags":["topo","vtctld","replication-graph"],"backgroundTag":"topo-server-unreachable","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}