diff --git a/tddb/td/db/binlog/Binlog.cpp b/tddb/td/db/binlog/Binlog.cpp index 77240da68..ddd6a723c 100644 --- a/tddb/td/db/binlog/Binlog.cpp +++ b/tddb/td/db/binlog/Binlog.cpp @@ -549,6 +549,7 @@ Status Binlog::load_binlog(const Callback &callback, const Callback &debug_callb } auto offset = processor_->offset(); + CHECK(offset >= 0); processor_->for_each([&](BinlogEvent &event) { VLOG(binlog) << "Replay binlog event: " << event.public_to_string(); if (callback) { diff --git a/tddb/td/db/binlog/BinlogEvent.cpp b/tddb/td/db/binlog/BinlogEvent.cpp index df2593b51..0b0801815 100644 --- a/tddb/td/db/binlog/BinlogEvent.cpp +++ b/tddb/td/db/binlog/BinlogEvent.cpp @@ -29,6 +29,7 @@ void BinlogEvent::init(BufferSlice &&raw_event) { } Slice BinlogEvent::get_data() const { + CHECK(raw_event_.size() >= MIN_SIZE); return Slice(raw_event_.as_slice().data() + HEADER_SIZE, size_ - MIN_SIZE); } diff --git a/tddb/td/db/binlog/BinlogEvent.h b/tddb/td/db/binlog/BinlogEvent.h index c80334de4..0127163ba 100644 --- a/tddb/td/db/binlog/BinlogEvent.h +++ b/tddb/td/db/binlog/BinlogEvent.h @@ -53,7 +53,7 @@ struct BinlogEvent { static constexpr size_t TAIL_SIZE = 4; static constexpr size_t MIN_SIZE = HEADER_SIZE + TAIL_SIZE; - int64 offset_; + int64 offset_ = -1; uint32 size_; uint64 id_; diff --git a/tddb/td/db/binlog/detail/BinlogEventsProcessor.cpp b/tddb/td/db/binlog/detail/BinlogEventsProcessor.cpp index f1d740eaa..405c31104 100644 --- a/tddb/td/db/binlog/detail/BinlogEventsProcessor.cpp +++ b/tddb/td/db/binlog/detail/BinlogEventsProcessor.cpp @@ -37,8 +37,8 @@ Status BinlogEventsProcessor::do_event(BinlogEvent &&event) { // just skip service events } else { if (!(event_ids_.empty() || event_ids_.back() < fixed_event_id)) { - return Status::Error(PSLICE() << offset_ << " " << event_ids_.size() << " " << event_ids_.back() << " " - << fixed_event_id << " " << event.public_to_string() << " " << total_events_ << " " + return Status::Error(PSLICE() << offset_ << ' ' << event_ids_.size() << ' ' << event_ids_.back() << ' ' + << fixed_event_id << ' ' << event.public_to_string() << ' ' << total_events_ << ' ' << total_raw_events_size_); } last_event_id_ = event.id_;