Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: PD should return err if cluster-id is zero . #5411

Closed
bufferflies opened this issue Aug 8, 2022 · 2 comments · Fixed by #5412
Closed

bug: PD should return err if cluster-id is zero . #5411

bufferflies opened this issue Aug 8, 2022 · 2 comments · Fixed by #5412

Comments

@bufferflies
Copy link
Contributor

bufferflies commented Aug 8, 2022

Bug Report

PD should return err if the cluster id is not ready.

tikv log: 2022/08/06 21:24:57.425 +00:00 no longer belongs to cluster 7128727844455161346, it is in 0
pd log:[2022/08/06 21:24:57.435 +00:00] [INFO] [server.go:376] ["init cluster id"] [cluster-id=7128727844455161346]

related code:

pd/server/grpc_service.go

Lines 103 to 145 in 989134e

func (s *GrpcServer) GetMembers(context.Context, *pdpb.GetMembersRequest) (*pdpb.GetMembersResponse, error) {
// Here we purposely do not check the cluster ID because the client does not know the correct cluster ID
// 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
}
var etcdLeader, pdLeader *pdpb.Member
leaderID := s.member.GetEtcdLeader()
for _, m := range members {
if m.MemberId == leaderID {
etcdLeader = m
break
}
}
tsoAllocatorManager := s.GetTSOAllocatorManager()
tsoAllocatorLeaders, err := tsoAllocatorManager.GetLocalAllocatorLeaders()
if err != nil {
return &pdpb.GetMembersResponse{
Header: s.wrapErrorToHeader(pdpb.ErrorType_UNKNOWN, err.Error()),
}, nil
}
leader := s.member.GetLeader()
for _, m := range members {
if m.MemberId == leader.GetMemberId() {
pdLeader = m
break
}
}
return &pdpb.GetMembersResponse{
Header: s.header(),
Members: members,
Leader: pdLeader,
EtcdLeader: etcdLeader,
TsoAllocatorLeaders: tsoAllocatorLeaders,
}, nil
}

and

pd/server/grpc_service.go

Lines 1506 to 1511 in 989134e

func (s *GrpcServer) errorHeader(err *pdpb.Error) *pdpb.ResponseHeader {
return &pdpb.ResponseHeader{
ClusterId: s.clusterID,
Error: err,
}
}

What did you do?

transfer leader

What did you expect to see?

normal

What did you see instead?

tikv panic, the log is:
2022/08/06 21:24:57.425 +00:00 no longer belongs to cluster 7128727844455161346, it is in 0

What version of PD are you using (pd-server -V)?

master

@bufferflies bufferflies added the type/bug The issue is confirmed as a bug. label Aug 8, 2022
@bufferflies
Copy link
Contributor Author

/assign @HuSharp

@ti-chi-bot
Copy link
Member

@bufferflies: GitHub didn't allow me to assign the following users: HuSharp.

Note that only tikv members, repo collaborators and people who have commented on this issue/PR can be assigned. Additionally, issues/PRs can only have 10 assignees at the same time.
For more information please see the contributor guide

In response to this:

/assign @HuSharp

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@bufferflies bufferflies self-assigned this Aug 8, 2022
ti-chi-bot added a commit that referenced this issue Aug 11, 2022
close #5411

Signed-off-by: bufferflies <1045931706@qq.com>

Co-authored-by: Ti Chi Robot <ti-community-prow-bot@tidb.io>
ti-chi-bot pushed a commit to ti-chi-bot/pd that referenced this issue Aug 11, 2022
close tikv#5411

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
ti-chi-bot pushed a commit to ti-chi-bot/pd that referenced this issue Aug 11, 2022
close tikv#5411

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
ti-chi-bot pushed a commit to ti-chi-bot/pd that referenced this issue Aug 11, 2022
close tikv#5411

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
ti-chi-bot pushed a commit to ti-chi-bot/pd that referenced this issue Aug 11, 2022
close tikv#5411

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
ti-chi-bot added a commit that referenced this issue Aug 11, 2022
close #5411, ref #5412

Signed-off-by: bufferflies <1045931706@qq.com>

Co-authored-by: bufferflies <1045931706@qq.com>
ti-chi-bot added a commit that referenced this issue Aug 16, 2022
close #5411, ref #5412

Signed-off-by: bufferflies <1045931706@qq.com>

Co-authored-by: bufferflies <1045931706@qq.com>
ti-chi-bot added a commit that referenced this issue Aug 29, 2022
close #5411, ref #5412

Signed-off-by: bufferflies <1045931706@qq.com>

Co-authored-by: bufferflies <1045931706@qq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants