From c7d44292bddcd309eec93a818dcb364c20cdd30a Mon Sep 17 00:00:00 2001 From: lhy1024 Date: Fri, 16 Aug 2024 01:22:11 +0800 Subject: [PATCH] mcs: fix potential data race in scheduling server Signed-off-by: lhy1024 --- pkg/mcs/scheduling/server/server.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/mcs/scheduling/server/server.go b/pkg/mcs/scheduling/server/server.go index 47a7cf9962b..093b759ce1c 100644 --- a/pkg/mcs/scheduling/server/server.go +++ b/pkg/mcs/scheduling/server/server.go @@ -207,6 +207,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 {