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

mcs: fix potential data race in scheduling server #8539

Merged
merged 3 commits into from
Aug 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion pkg/mcs/scheduling/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import (
"github.com/tikv/pd/pkg/storage/endpoint"
"github.com/tikv/pd/pkg/storage/kv"
"github.com/tikv/pd/pkg/utils/apiutil"
"github.com/tikv/pd/pkg/utils/etcdutil"
"github.com/tikv/pd/pkg/utils/grpcutil"
"github.com/tikv/pd/pkg/utils/logutil"
"github.com/tikv/pd/pkg/utils/memberutil"
Expand Down Expand Up @@ -193,7 +194,7 @@ func (s *Server) updateAPIServerMemberLoop() {
if !s.IsServing() {
continue
}
members, err := s.GetClient().MemberList(ctx)
members, err := etcdutil.ListEtcdMembers(ctx, s.GetClient())
if err != nil {
log.Warn("failed to list members", errs.ZapError(err))
continue
Expand All @@ -212,6 +213,11 @@ func (s *Server) updateAPIServerMemberLoop() {
cc, err := s.GetDelegateClient(ctx, s.GetTLSConfig(), ep.ClientURLs[0])
if err != nil {
log.Info("failed to get delegate client", errs.ZapError(err))
continue
}
if !s.IsServing() {
// double check
break
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to add a break label to indicate jumping out of the “for loop”?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is not necessary.

}
if s.cluster.SwitchAPIServerLeader(pdpb.NewPDClient(cc)) {
if status.Leader != curLeader {
Expand Down
Loading