Skip to content

Commit

Permalink
Return GetMembers error as a gRPC error to let TiKV retry
Browse files Browse the repository at this point in the history
Signed-off-by: JmPotato <ghzpotato@gmail.com>
  • Loading branch information
JmPotato committed Aug 8, 2022
1 parent a56d771 commit a9f7a06
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions server/grpc_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,8 @@ func (s *GrpcServer) GetMembers(context.Context, *pdpb.GetMembersRequest) (*pdpb
// at startup and needs to get the cluster ID with the first request (i.e. GetMembers).
members, err := s.Server.GetMembers()
if err != nil {
return &pdpb.GetMembersResponse{
Header: s.wrapErrorToHeader(pdpb.ErrorType_UNKNOWN, err.Error()),
}, nil
// Should return a gRPC error to let the client, e.g, TiKV, retry.
return nil, status.Errorf(codes.Unknown, err.Error())
}

var etcdLeader, pdLeader *pdpb.Member
Expand All @@ -122,9 +121,7 @@ func (s *GrpcServer) GetMembers(context.Context, *pdpb.GetMembersRequest) (*pdpb
tsoAllocatorManager := s.GetTSOAllocatorManager()
tsoAllocatorLeaders, err := tsoAllocatorManager.GetLocalAllocatorLeaders()
if err != nil {
return &pdpb.GetMembersResponse{
Header: s.wrapErrorToHeader(pdpb.ErrorType_UNKNOWN, err.Error()),
}, nil
return nil, status.Errorf(codes.Unknown, err.Error())
}

leader := s.member.GetLeader()
Expand Down

0 comments on commit a9f7a06

Please sign in to comment.