Skip to content

Commit 369d7bc

Browse files
authored
ddl: relax the check in ownerCheckAllVersions (#46752) (#46794)
close #46751
1 parent 0d9903c commit 369d7bc

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

ddl/syncer/syncer.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,13 +337,15 @@ func (s *schemaVersionSyncer) OwnerCheckAllVersions(ctx context.Context, jobID i
337337
if variable.EnableMDL.Load() {
338338
for _, kv := range resp.Kvs {
339339
key := string(kv.Key)
340+
tidbIDInResp := key[strings.LastIndex(key, "/")+1:]
340341
ver, err := strconv.Atoi(string(kv.Value))
341342
if err != nil {
342343
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))
343344
succ = false
344345
break
345346
}
346-
if int64(ver) < latestVer {
347+
// We need to check if the tidb ID is in the updatedMap, in case that deleting etcd is failed, and tidb server is down.
348+
if int64(ver) < latestVer && updatedMap[tidbIDInResp] != "" {
347349
if notMatchVerCnt%intervalCnt == 0 {
348350
logutil.BgLogger().Info("[ddl] syncer check all versions, someone is not synced, continue checking",
349351
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
352354
notMatchVerCnt++
353355
break
354356
}
355-
delete(updatedMap, key[strings.LastIndex(key, "/")+1:])
357+
delete(updatedMap, tidbIDInResp)
356358
}
357359
if len(updatedMap) > 0 {
358360
succ = false

0 commit comments

Comments
 (0)