Skip to content

Commit

Permalink
mcs: fix panic of GetMinTS (tikv#7529)
Browse files Browse the repository at this point in the history
close tikv#7528

Signed-off-by: Ryan Leung <rleungx@gmail.com>

Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
  • Loading branch information
rleungx and ti-chi-bot[bot] authored Dec 12, 2023
1 parent fcdeec4 commit ab97b9a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions server/grpc_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,11 +328,11 @@ func (s *GrpcServer) GetMinTSFromTSOService(dcLocation string) (*pdpb.Timestamp,

// Get the minimal timestamp from the TSO servers/pods
var mutex syncutil.Mutex
resps := make([]*tsopb.GetMinTSResponse, len(addrs))
resps := make([]*tsopb.GetMinTSResponse, 0)
wg := sync.WaitGroup{}
wg.Add(len(addrs))
for idx, addr := range addrs {
go func(idx int, addr string) {
for _, addr := range addrs {
go func(addr string) {
defer wg.Done()
resp, err := s.getMinTSFromSingleServer(s.ctx, dcLocation, addr)
if err != nil || resp == nil {
Expand All @@ -342,8 +342,8 @@ func (s *GrpcServer) GetMinTSFromTSOService(dcLocation string) (*pdpb.Timestamp,
}
mutex.Lock()
defer mutex.Unlock()
resps[idx] = resp
}(idx, addr)
resps = append(resps, resp)
}(addr)
}
wg.Wait()

Expand Down

0 comments on commit ab97b9a

Please sign in to comment.