Skip to content

Commit

Permalink
mcs: fix datarace in keyspace group
Browse files Browse the repository at this point in the history
Signed-off-by: lhy1024 <[email protected]>
  • Loading branch information
lhy1024 committed Jun 29, 2023
1 parent fa721e7 commit 6c7c945
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/tso/keyspace_group_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,12 @@ func (s *state) getKeyspaceGroupMeta(
) (*AllocatorManager, *endpoint.KeyspaceGroup) {
s.RLock()
defer s.RUnlock()
return s.ams[groupID], s.kgs[groupID]
am := s.ams[groupID]
if s.kgs[groupID] == nil {
return am, nil
}
kg := *s.kgs[groupID] // copy the keyspace group meta to avoid datarace
return am, &kg
}

// getKeyspaceGroupMetaWithCheck returns the keyspace group meta of the given keyspace.
Expand Down

0 comments on commit 6c7c945

Please sign in to comment.