Skip to content

Commit

Permalink
mcs: fix potential data race in scheduling server (#8539)
Browse files Browse the repository at this point in the history
close #8538

Signed-off-by: lhy1024 <[email protected]>

Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
  • Loading branch information
lhy1024 and ti-chi-bot[bot] committed Aug 21, 2024
1 parent 2e8f20f commit 9c14c63
Showing 1 changed file with 7 additions and 1 deletion.
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
}
if s.cluster.SwitchAPIServerLeader(pdpb.NewPDClient(cc)) {
if status.Leader != curLeader {
Expand Down

0 comments on commit 9c14c63

Please sign in to comment.