Skip to content

Commit 1de5d27

Browse files
committed
change
1 parent 817c4d6 commit 1de5d27

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

pkg/ddl/syncer/syncer.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ func (s *schemaVersionSyncer) syncJobSchemaVer(ctx context.Context) {
500500
}
501501

502502
func (s *schemaVersionSyncer) handleJobSchemaVerKV(kv *mvccpb.KeyValue, tp mvccpb.Event_EventType) {
503-
jobID, tidbID, schemaVer, valid := decodeJobVersionEvent(kv, s.jobNodeVerPrefix)
503+
jobID, tidbID, schemaVer, valid := decodeJobVersionEvent(kv, tp, s.jobNodeVerPrefix)
504504
if !valid {
505505
logutil.DDLLogger().Error("invalid job version kv", zap.Stringer("kv", kv), zap.Stringer("type", tp))
506506
return
@@ -543,7 +543,7 @@ func (s *schemaVersionSyncer) jobSchemaVerMatchOrSet(jobID int64, matchFn func(m
543543
return item
544544
}
545545

546-
func decodeJobVersionEvent(kv *mvccpb.KeyValue, prefix string) (jobID int64, tidbID string, schemaVer int64, valid bool) {
546+
func decodeJobVersionEvent(kv *mvccpb.KeyValue, tp mvccpb.Event_EventType, prefix string) (jobID int64, tidbID string, schemaVer int64, valid bool) {
547547
left := strings.TrimPrefix(string(kv.Key), prefix)
548548
parts := strings.Split(left, "/")
549549
if len(parts) != 2 {
@@ -553,9 +553,12 @@ func decodeJobVersionEvent(kv *mvccpb.KeyValue, prefix string) (jobID int64, tid
553553
if err != nil {
554554
return 0, "", 0, false
555555
}
556-
schemaVer, err = strconv.ParseInt(string(kv.Value), 10, 64)
557-
if err != nil {
558-
return 0, "", 0, false
556+
// there is Value in DELETE event, so we need to check it.
557+
if tp == mvccpb.PUT {
558+
schemaVer, err = strconv.ParseInt(string(kv.Value), 10, 64)
559+
if err != nil {
560+
return 0, "", 0, false
561+
}
559562
}
560563
return jobID, parts[1], schemaVer, true
561564
}

0 commit comments

Comments
 (0)