Log and abort on critical binlog error

GitOrigin-RevId: 13f7b562c42cda0d5e89e522f12e4aecc2330382
This commit is contained in:
Arseny Smirnov 2018-07-09 13:23:34 +03:00
parent 1cf26c2eab
commit 9fa03cbda4

View File

@ -121,9 +121,9 @@ class BinlogReader {
return Status::Error(PSLICE() << "Too small event " << tag("size", size_));
}
if (size_ % 4 != 0) {
LOG(FATAL) << "Event of size " << size_ << " at offset " << offset() << " out of " << expected_size_ << ' '
return Status::Error(-2, PSLICE() << "Event of size " << size_ << " at offset " << offset() << " out of " << expected_size_ << ' '
<< tag("is_encrypted", is_encrypted_)
<< format::as_hex_dump<4>(Slice(input_->prepare_read().truncate(28)));
<< format::as_hex_dump<4>(Slice(input_->prepare_read().truncate(28))));
}
state_ = ReadEvent;
}
@ -464,6 +464,11 @@ Status Binlog::load_binlog(const Callback &callback, const Callback &debug_callb
BinlogEvent event;
auto r_need_size = reader.read_next(&event);
if (r_need_size.is_error()) {
if (r_need_size.error().code() == -2) {
fd_.seek(reader.offset()).ensure();
fd_.truncate_to_current_position(reader.offset()).ensure();
LOG(FATAL) << r_need_size.error();
}
LOG(ERROR) << r_need_size.error();
break;
}