diff --git a/autoid_service/autoid.go b/autoid_service/autoid.go index b7d4e3ed6275b..2bc2ee56c2a8d 100644 --- a/autoid_service/autoid.go +++ b/autoid_service/autoid.go @@ -325,7 +325,7 @@ func MockForTest(store kv.Storage) autoid.AutoIDAllocClient { // Close closes the Service and clean up resource. func (s *Service) Close() { - if s.leaderShip != nil { + if s.leaderShip != nil && s.leaderShip.IsOwner() { for k, v := range s.autoIDMap { if v.base > 0 { err := v.forceRebase(context.Background(), s.store, k.dbID, k.tblID, v.base, v.isUnsigned)