From 2320ba988bc4544d392f7de4611a96493cbad96f Mon Sep 17 00:00:00 2001 From: wjhuang2016 Date: Thu, 7 Sep 2023 17:38:37 +0800 Subject: [PATCH] done Signed-off-by: wjhuang2016 --- ddl/syncer/syncer.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ddl/syncer/syncer.go b/ddl/syncer/syncer.go index 0478973d4656f..82ca036b1207b 100644 --- a/ddl/syncer/syncer.go +++ b/ddl/syncer/syncer.go @@ -337,13 +337,15 @@ func (s *schemaVersionSyncer) OwnerCheckAllVersions(ctx context.Context, jobID i if variable.EnableMDL.Load() { for _, kv := range resp.Kvs { key := string(kv.Key) + tidbIDInResp := key[strings.LastIndex(key, "/")+1:] ver, err := strconv.Atoi(string(kv.Value)) if err != nil { logutil.BgLogger().Info("[ddl] syncer check all versions, convert value to int failed, continue checking.", zap.String("ddl", string(kv.Key)), zap.String("value", string(kv.Value)), zap.Error(err)) succ = false break } - if int64(ver) < latestVer { + // We need to check if the tidb ID is in the updatedMap, in case that deleting etcd is failed, and tidb server is down. + if int64(ver) < latestVer && updatedMap[tidbIDInResp] != "" { if notMatchVerCnt%intervalCnt == 0 { logutil.BgLogger().Info("[ddl] syncer check all versions, someone is not synced, continue checking", zap.String("ddl", string(kv.Key)), zap.Int("currentVer", ver), zap.Int64("latestVer", latestVer)) @@ -352,7 +354,7 @@ func (s *schemaVersionSyncer) OwnerCheckAllVersions(ctx context.Context, jobID i notMatchVerCnt++ break } - delete(updatedMap, key[strings.LastIndex(key, "/")+1:]) + delete(updatedMap, tidbIDInResp) } if len(updatedMap) > 0 { succ = false