diff --git a/cdc/kv/matcher.go b/cdc/kv/matcher.go index b6a7c657d74..233d00ab14c 100644 --- a/cdc/kv/matcher.go +++ b/cdc/kv/matcher.go @@ -26,7 +26,14 @@ func newMatcher() *matcher { } func (m *matcher) putPrewriteRow(row *cdcpb.Event_Row) { - m.unmatchedValue[newMatchKey(row)] = row.GetValue() + key := newMatchKey(row) + value := row.GetValue() + // tikv may send a prewrite event with empty value + // here we need to avoid the invalid prewrite event overwrite the value + if _, exist := m.unmatchedValue[key]; exist && len(value) == 0 { + return + } + m.unmatchedValue[key] = value } func (m *matcher) matchRow(row *cdcpb.Event_Row) ([]byte, bool) {