From e63b0537dbaa3ce1641ec256277e34a72ae6b3f8 Mon Sep 17 00:00:00 2001 From: tiancaiamao Date: Wed, 30 Aug 2023 15:26:08 +0800 Subject: [PATCH] autoid_service: fix potential 'duplicated entry' error when tidb exit for AUTO_ID_CACHE=1 tables (#46445) close pingcap/tidb#46444 --- autoid_service/autoid.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoid_service/autoid.go b/autoid_service/autoid.go index 1a4d2b426263e..f7142c1e117b1 100644 --- a/autoid_service/autoid.go +++ b/autoid_service/autoid.go @@ -317,7 +317,7 @@ func MockForTest(store kv.Storage) *mockClient { // 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)