Skip to content

Commit

Permalink
fix datarace
Browse files Browse the repository at this point in the history
Signed-off-by: lhy1024 <admin@liudos.us>
  • Loading branch information
lhy1024 committed Jun 29, 2023
1 parent 38a1cc5 commit 89f99e8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/tso/keyspace_group_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,12 @@ func (s *state) getKeyspaceGroupMeta(
) (*AllocatorManager, *endpoint.KeyspaceGroup) {
s.RLock()
defer s.RUnlock()
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 s.ams[groupID], &kg
return am, &kg
}

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

0 comments on commit 89f99e8

Please sign in to comment.