autoid_service: fix potential 'duplicated entry' error when tidb exit for AUTO_ID_CACHE=1 tables (#46445)

close pingcap/tidb#46444
This commit is contained in:
tiancaiamao
2023-08-30 15:26:08 +08:00
committed by GitHub
parent 99738a3b9b
commit f516603252

View File

@ -327,7 +327,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)