{"record":{"id":"326d809d8dde4836","repo":"vitessio/vitess","slug":"gettabletmap-failed-v","errorCode":null,"errorMessage":"GetTabletMap() failed: %v","messagePattern":"GetTabletMap\\(\\) failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/wrangler/shard.go","lineNumber":118,"sourceCode":"\t\t\t}\n\t\tcase err == nil:\n\t\t\t// We found a ShardReplication object. We\n\t\t\t// trust it to have all tablet records.\n\t\t\taliases = make([]*topodatapb.TabletAlias, len(sri.Nodes))\n\t\t\tfor i, n := range sri.Nodes {\n\t\t\t\taliases[i] = n.TabletAlias\n\t\t\t}\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"GetShardReplication(%v, %v, %v) failed: %v\", cell, keyspace, shard, err)\n\t\t}\n\n\t\t// Get the corresponding Tablet records. Note\n\t\t// GetTabletMap ignores ErrNoNode, and it's good for\n\t\t// our purpose, it means a tablet was deleted but is\n\t\t// still referenced.\n\t\ttabletMap, err := wr.ts.GetTabletMap(ctx, aliases, nil)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"GetTabletMap() failed: %v\", err)\n\t\t}\n\n\t\t// Remove the tablets that don't belong to our\n\t\t// keyspace/shard from the map.\n\t\tfor a, ti := range tabletMap {\n\t\t\tif ti.Keyspace != keyspace || ti.Shard != shard {\n\t\t\t\tdelete(tabletMap, a)\n\t\t\t}\n\t\t}\n\n\t\t// Now see if we need to DeleteTablet, and if we can, do it.\n\t\tif len(tabletMap) > 0 {\n\t\t\tif !recursive {\n\t\t\t\treturn fmt.Errorf(\"shard %v/%v still has %v tablets in cell %v; use -recursive or remove them manually\", keyspace, shard, len(tabletMap), cell)\n\t\t\t}\n\n\t\t\twr.Logger().Infof(\"Deleting all tablets in shard %v/%v cell %v\", keyspace, shard, cell)\n\t\t\tfor tabletAlias, tabletInfo := range tabletMap {","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/wrangler/shard.go#L100-L136","documentation":"DeleteShard first gathers all tablet aliases registered for the shard, then loads their full records via topo.Server.GetTabletMap. That call aggregates per-tablet lookup errors; if it fails for a reason other than a single missing node (e.g. topo server connection issues), DeleteShard aborts with this wrapped message.","triggerScenarios":"Calling DeleteShard (via `vtctldclient DeleteShard`) when the topo server cannot read one or more tablet records — e.g. topo server outage, permission errors, or malformed tablet records — and GetTabletMap returns a non-nil error other than ignorable ErrNoNode entries.","commonSituations":"Zookeeper/etcd connectivity problems during shard teardown; a partially deleted shard where topo reads fail intermittently; run with wrong topo flags pointing at the wrong topo server.","solutions":["Check connectivity to the topo server (zk/etcd) and retry the DeleteShard command; DeleteShard is idempotent for already-deleted tablets.","Inspect the wrapped inner error (`%v` at the end of the message) to identify which tablet alias or topo operation failed.","Verify vtctld is started with the correct topo server flags (--topo_implementation, --topo_global_server_address, --topo_global_root).","If a specific tablet record is corrupt, delete it with `vtctldclient DeleteTablet <alias>` and re-run DeleteShard."],"exampleFix":"// before\nvtctldclient --server :15999 DeleteShard commerce/0\n// fails with topo read error\n// after\n# fix topo connectivity, then retry\nvtctldclient --server :15999 --topo_implementation etcd2 --topo_global_server_address localhost:2379 DeleteShard commerce/0","handlingStrategy":"retry","validationCode":"// Go: verify topo reachability before DeleteShard\naliases, err := ts.GetTabletAliasesByShard(ctx, keyspace, shard)\nif err != nil {\n    return fmt.Errorf(\"topo not readable, aborting DeleteShard: %w\", err)\n}\n_ = aliases","typeGuard":null,"tryCatchPattern":"// Go: retry transient topo errors\nvar lastErr error\nfor i := 0; i < 3; i++ {\n    err := wr.DeleteShard(ctx, keyspace, shard, nil, true)\n    if err == nil {\n        return nil\n    }\n    lastErr = err\n    if strings.Contains(err.Error(), \"GetTabletMap() failed\") {\n        time.Sleep(2 * time.Second)\n        continue\n    }\n    break\n}\nreturn lastErr","preventionTips":["Monitor topo server (zk/etcd) health before running destructive workflows","Pass correct topo flags to vtctldclient","Retry DeleteShard — it is idempotent for already-deleted tablets"],"tags":["topo","topology","shard-deletion","wrangler"],"backgroundTag":"topo-server-unavailable","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}