{"record":{"id":"083247c1c21cd5ad","repo":"vitessio/vitess","slug":"failed-to-get-tablet-s-w","errorCode":null,"errorMessage":"failed to get tablet %s: %w","messagePattern":"failed to get tablet (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vtctl/grpcvtctldserver/server.go","lineNumber":3412,"sourceCode":"\n// RefreshState is part of the vtctldservicepb.VtctldServer interface.\nfunc (s *VtctldServer) RefreshState(ctx context.Context, req *vtctldatapb.RefreshStateRequest) (resp *vtctldatapb.RefreshStateResponse, err error) {\n\tspan, ctx := trace.NewSpan(ctx, \"VtctldServer.RefreshState\")\n\tdefer span.Finish()\n\n\tdefer panicHandler(&err)\n\n\tif req.TabletAlias == nil {\n\t\terr = vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, \"RefreshState requires a tablet alias\")\n\t\treturn nil, err\n\t}\n\n\tctx, cancel := context.WithTimeout(ctx, topo.RemoteOperationTimeout)\n\tdefer cancel()\n\n\ttablet, err := s.ts.GetTablet(ctx, req.TabletAlias)\n\tif err != nil {\n\t\terr = fmt.Errorf(\"failed to get tablet %s: %w\", topoproto.TabletAliasString(req.TabletAlias), err)\n\t\treturn nil, err\n\t}\n\n\tif err = s.tmc.RefreshState(ctx, tablet.Tablet); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &vtctldatapb.RefreshStateResponse{}, nil\n}\n\n// RefreshStateByShard is part of the vtctldservicepb.VtctldServer interface.\nfunc (s *VtctldServer) RefreshStateByShard(ctx context.Context, req *vtctldatapb.RefreshStateByShardRequest) (resp *vtctldatapb.RefreshStateByShardResponse, err error) {\n\tspan, ctx := trace.NewSpan(ctx, \"VtctldServer.RefreshStateByShard\")\n\tdefer span.Finish()\n\n\tdefer panicHandler(&err)\n\n\tif req.Keyspace == \"\" {","sourceCodeStart":3394,"sourceCodeEnd":3430,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vtctl/grpcvtctldserver/server.go#L3394-L3430","documentation":"RefreshState (ReparentTable-related) first resolves the tablet alias via topo.GetTablet. If the alias does not exist in the topology, the lookup error is wrapped with the alias and returned to the caller.","triggerScenarios":"vtctldclient RefreshTablet / ReparentTable-style RPC with a tablet alias that was scrapped, deleted, mistyped, or whose topo entry was removed.","commonSituations":"Stale alias in scripts after tablet decommission; typo in alias; topo server data cleaned up (e.g. after keyspace removal); cross-cell alias confusion.","solutions":["List valid tablets with `vtctldclient GetTablets` and use the correct alias","Re-check alias format (cell-uid format, e.g. zone1-0000000100)","If the tablet exists but topo entry is missing, re-register it (RestartTablet / vttablet restart)","Fix automation scripts referencing deleted tablets"],"exampleFix":"// before\nvtctldclient RefreshState zone1-0000999999  # not in topo\n// after\nvtctldclient GetTablets | grep zone1\nvtctldclient RefreshState zone1-0000000100","handlingStrategy":"validation","validationCode":"// validate the alias exists before calling RefreshState\ntablets, _ := vtctld.GetTablets(ctx)\nif !slices.ContainsFunc(tablets, func(t Tablet) bool {\n    return t.Alias == req.Alias\n}) {\n    return fmt.Errorf(\"unknown tablet alias %s\", req.Alias)\n}","typeGuard":null,"tryCatchPattern":"// handle missing tablet distinctly from RPC failures\nvar notFound bool\nif errors.As(err, &topoErr) && errors.Is(topoErr, topo.ErrNodeNotFound) {\n    notFound = true // skip or re-register tablet\n}","preventionTips":["Regenerate aliases dynamically from GetTablets, never hardcode","Clean aliases from configs when tablets are scrapped","Use topoproto.TabletAliasString consistently to format aliases","Alert on topo entries pointing at decommissioned tablets"],"tags":["vtctld","topology","tablet-lookup"],"backgroundTag":"tablet-not-found","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}