From f5fa144d47922df8dbb1e5589154d872465b2d60 Mon Sep 17 00:00:00 2001 From: tiancaiamao Date: Mon, 28 Aug 2023 15:07:16 +0800 Subject: [PATCH] autoid_service: fix potential 'duplicated entry' error when tidb exit for AUTO_ID_CACHE=1 tables --- 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 aa6c487cb0b48..198c75db91020 100644 --- a/autoid_service/autoid.go +++ b/autoid_service/autoid.go @@ -322,7 +322,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)