diff --git a/tddb/td/db/binlog/Binlog.cpp b/tddb/td/db/binlog/Binlog.cpp index 68b15010..492b52c0 100644 --- a/tddb/td/db/binlog/Binlog.cpp +++ b/tddb/td/db/binlog/Binlog.cpp @@ -344,7 +344,6 @@ void Binlog::do_event(BinlogEvent &&event) { update_write_encryption(); //LOG(INFO) << format::cond(state_ == State::Run, "Run", "Reindex") << ": init encryption"; } - return; } } diff --git a/tddb/td/db/binlog/detail/BinlogEventsProcessor.cpp b/tddb/td/db/binlog/detail/BinlogEventsProcessor.cpp index 50ad91bf..ce769998 100644 --- a/tddb/td/db/binlog/detail/BinlogEventsProcessor.cpp +++ b/tddb/td/db/binlog/detail/BinlogEventsProcessor.cpp @@ -32,8 +32,8 @@ void BinlogEventsProcessor::do_event(BinlogEvent &&event) { total_raw_events_size_ += static_cast(event.raw_event_.size()); events_[pos] = std::move(event); } - } else if (event.type_ == BinlogEvent::ServiceTypes::Empty) { - // just skip this event + } else if (event.type_ < 0) { + // just skip service events } else { CHECK(ids_.empty() || ids_.back() < fixed_id); last_id_ = event.id_; diff --git a/test/db.cpp b/test/db.cpp index fe19b51c..e66b7632 100644 --- a/test/db.cpp +++ b/test/db.cpp @@ -34,6 +34,22 @@ static typename ContainerT::value_type &rand_elem(ContainerT &cont) { return cont[Random::fast(0, static_cast(cont.size()) - 1)]; } +TEST(DB, binlog_encryption_bug) { + CSlice binlog_name = "test_binlog"; + Binlog::destroy(binlog_name).ignore(); + + auto cucumber = DbKey::password("cucumber"); + auto empty = DbKey::empty(); + { + Binlog binlog; + binlog.init(binlog_name.str(), [&](const BinlogEvent &x) {}, cucumber).ensure(); + } + { + Binlog binlog; + binlog.init(binlog_name.str(), [&](const BinlogEvent &x) {}, cucumber).ensure(); + } +} + TEST(DB, binlog_encryption) { CSlice binlog_name = "test_binlog"; Binlog::destroy(binlog_name).ignore();