From a0eb27212a97f2c174f99aed4cfed7800b071bcf Mon Sep 17 00:00:00 2001 From: Bin Shi Date: Tue, 25 Apr 2023 10:05:17 -0700 Subject: [PATCH] fix Nil pointer deference when (*AllocatorManager).GetMember If the desired keyspace group fall back to the default keyspace group and the AM isn't initialized, return not served error. Signed-off-by: Bin Shi --- pkg/tso/keyspace_group_manager.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/tso/keyspace_group_manager.go b/pkg/tso/keyspace_group_manager.go index 9370e8664d1..8e8e2fb6eff 100644 --- a/pkg/tso/keyspace_group_manager.go +++ b/pkg/tso/keyspace_group_manager.go @@ -137,6 +137,9 @@ func (s *state) getAMWithMembershipCheck( // The keyspace doesn't belong to any keyspace group, so return the default keyspace group. // It's for migrating the existing keyspaces which have no keyspace group assigned, so the // the default keyspace group is used to serve the keyspaces. + if s.ams[mcsutils.DefaultKeyspaceGroupID] == nil { + return nil, mcsutils.DefaultKeyspaceGroupID, errs.ErrKeyspaceNotAssigned.FastGenByArgs(keyspaceID) + } return s.ams[mcsutils.DefaultKeyspaceGroupID], mcsutils.DefaultKeyspaceGroupID, nil }