filter out invalid k-v events when applying kv-file on PiTR
close tikv/tikv#13853, ref pingcap/tidb#39398
@@ -1017,8 +1017,13 @@ where
{
// use callback to collect kv data.
Box::new(move |k: Vec<u8>, v: Vec<u8>| {
- let mut req = Request::default();
+ // Need to skip the empty key/value that could break the transaction or cause
+ // data corruption. see details at https://github.com/pingcap/tiflow/issues/5468.
+ if k.is_empty() || v.is_empty() {
+ return;
+ }
+ let mut req = Request::default();
if is_delete {
let mut del = DeleteRequest::default();
del.set_key(k);
@@ -1201,6 +1206,7 @@ mod test {
write(b"bar", Put, 38, 37),
write(b"baz", Put, 34, 31),
write(b"bar", Put, 28, 17),
+ (Vec::default(), Vec::default()),
],
expected_reqs: vec![
write_req(b"foo", Put, 40, 39),
@@ -1235,6 +1241,7 @@ mod test {
),
default(b"beyond", b"Calling your name.", 278),
default(b"beyond", b"Calling your name.", 278),
+ default(b"PingCap", b"", 300),
],
expected_reqs: vec![
default_req(b"aria", b"The planet where flowers bloom.", 123),
