From 7fa145c33e968f182e2e353a36ed7f066255de07 Mon Sep 17 00:00:00 2001 From: Arseny Smirnov Date: Thu, 28 Jun 2018 20:00:11 +0300 Subject: [PATCH] Binlog: even more debug GitOrigin-RevId: 99585d14e3446dc1f5c4a4a7c1ba1e2b3aeef47e --- tddb/td/db/BinlogKeyValue.h | 4 ++-- tddb/td/db/binlog/Binlog.cpp | 4 +++- tddb/td/db/binlog/Binlog.h | 6 +++--- tddb/td/db/binlog/BinlogEvent.cpp | 2 +- tddb/td/db/binlog/BinlogEvent.h | 10 ++++++---- tddb/td/db/binlog/detail/BinlogEventsBuffer.h | 3 ++- 6 files changed, 17 insertions(+), 12 deletions(-) diff --git a/tddb/td/db/BinlogKeyValue.h b/tddb/td/db/BinlogKeyValue.h index e515677b..99361209 100644 --- a/tddb/td/db/BinlogKeyValue.h +++ b/tddb/td/db/BinlogKeyValue.h @@ -158,7 +158,7 @@ class BinlogKeyValue : public KeyValueSyncInterface { } void add_event(uint64 seq_no, BufferSlice &&event) { - binlog_->add_raw_event(seq_no, std::move(event)); + binlog_->add_raw_event(BinlogDebugInfo{__FILE__, __LINE__}, seq_no, std::move(event)); } bool isset(const string &key) override { @@ -237,7 +237,7 @@ class BinlogKeyValue : public KeyValueSyncInterface { }; template <> inline void BinlogKeyValue::add_event(uint64 seq_no, BufferSlice &&event) { - binlog_->add_raw_event(std::move(event)); + binlog_->add_raw_event(std::move(event), BinlogDebugInfo{__FILE__, __LINE__}); } template <> inline void BinlogKeyValue::force_sync(Promise<> &&promise) { diff --git a/tddb/td/db/binlog/Binlog.cpp b/tddb/td/db/binlog/Binlog.cpp index 3e207c05..30ca1d9a 100644 --- a/tddb/td/db/binlog/Binlog.cpp +++ b/tddb/td/db/binlog/Binlog.cpp @@ -125,6 +125,7 @@ class BinlogReader { return size_; } + event->debug_info_ = BinlogDebugInfo{__FILE__, __LINE__}; TRY_STATUS(event->init(input_->cut_head(size_).move_as_buffer_slice())); offset_ += size_; event->offset_ = offset_; @@ -557,7 +558,8 @@ void Binlog::reset_encryption() { event.key_hash_ = event.generate_hash(key.as_slice()); do_event(BinlogEvent( - BinlogEvent::create_raw(0, BinlogEvent::ServiceTypes::AesCtrEncryption, 0, create_default_storer(event)))); + BinlogEvent::create_raw(0, BinlogEvent::ServiceTypes::AesCtrEncryption, 0, create_default_storer(event)), + BinlogDebugInfo{__FILE__, __LINE__})); } void Binlog::do_reindex() { diff --git a/tddb/td/db/binlog/Binlog.h b/tddb/td/db/binlog/Binlog.h index c98da3aa..603c0ffb 100644 --- a/tddb/td/db/binlog/Binlog.h +++ b/tddb/td/db/binlog/Binlog.h @@ -67,9 +67,9 @@ class Binlog { return fd_.empty(); } - void add_raw_event(BufferSlice &&raw_event) { - add_event(BinlogEvent(std::move(raw_event))); - } + //void add_raw_event(BufferSlice &&raw_event) { + //add_event(BinlogEvent(std::move(raw_event))); + //} void add_raw_event(BufferSlice &&raw_event, BinlogDebugInfo info) { add_event(BinlogEvent(std::move(raw_event), info)); diff --git a/tddb/td/db/binlog/BinlogEvent.cpp b/tddb/td/db/binlog/BinlogEvent.cpp index cf27bd12..b9db884d 100644 --- a/tddb/td/db/binlog/BinlogEvent.cpp +++ b/tddb/td/db/binlog/BinlogEvent.cpp @@ -14,7 +14,7 @@ int32 VERBOSITY_NAME(binlog) = VERBOSITY_NAME(DEBUG) + 8; Status BinlogEvent::init(BufferSlice &&raw_event, bool check_crc) { TlParser parser(raw_event.as_slice()); size_ = parser.fetch_int(); - CHECK(size_ == raw_event.size()) << size_ << " " << raw_event.size(); + CHECK(size_ == raw_event.size()) << size_ << " " << raw_event.size() << debug_info_; id_ = parser.fetch_long(); type_ = parser.fetch_int(); flags_ = parser.fetch_int(); diff --git a/tddb/td/db/binlog/BinlogEvent.h b/tddb/td/db/binlog/BinlogEvent.h index d5e882ef..f9984211 100644 --- a/tddb/td/db/binlog/BinlogEvent.h +++ b/tddb/td/db/binlog/BinlogEvent.h @@ -81,6 +81,7 @@ struct BinlogEvent { } BinlogEvent clone() const { BinlogEvent result; + result.debug_info_ = BinlogDebugInfo{__FILE__, __LINE__}; result.init(raw_event_.clone()).ensure(); return result; } @@ -90,13 +91,14 @@ struct BinlogEvent { } BinlogEvent() = default; - explicit BinlogEvent(BufferSlice &&raw_event) { - init(std::move(raw_event), false).ensure(); - } + //explicit BinlogEvent(BufferSlice &&raw_event) { + //init(std::move(raw_event), false).ensure(); + //} explicit BinlogEvent(BufferSlice &&raw_event, BinlogDebugInfo info) { - init(std::move(raw_event), false).ensure(); debug_info_ = info; + init(std::move(raw_event), false).ensure(); } + Status init(BufferSlice &&raw_event, bool check_crc = true) TD_WARN_UNUSED_RESULT; static BufferSlice create_raw(uint64 id, int32 type, int32 flags, const Storer &storer); diff --git a/tddb/td/db/binlog/detail/BinlogEventsBuffer.h b/tddb/td/db/binlog/detail/BinlogEventsBuffer.h index dcd6d7c1..00d97e3b 100644 --- a/tddb/td/db/binlog/detail/BinlogEventsBuffer.h +++ b/tddb/td/db/binlog/detail/BinlogEventsBuffer.h @@ -23,7 +23,8 @@ class BinlogEventsBuffer { auto &event = events_[i]; if (i + 1 != ids_.size() && (event.flags_ & BinlogEvent::Flags::Partial) == 0) { callback(BinlogEvent(BinlogEvent::create_raw(event.id_, event.type_, event.flags_ | BinlogEvent::Flags::Partial, - create_storer(event.data_)))); + create_storer(event.data_)), + BinlogDebugInfo{__FILE__, __LINE__})); } else { callback(std::move(event)); }