diff --git a/tddb/td/db/binlog/Binlog.h b/tddb/td/db/binlog/Binlog.h index 762a4cfcc..8cae93f18 100644 --- a/tddb/td/db/binlog/Binlog.h +++ b/tddb/td/db/binlog/Binlog.h @@ -93,7 +93,10 @@ class Binlog { return seq_no; } - uint64 erase_batch(std::vector event_ids) { + uint64 erase_batch(vector event_ids) { + if (event_ids.empty()) { + return 0; + } auto seq_no = next_event_id(0); for (auto event_id : event_ids) { erase(event_id); diff --git a/tddb/td/db/binlog/BinlogInterface.h b/tddb/td/db/binlog/BinlogInterface.h index f27e351bd..d46297f94 100644 --- a/tddb/td/db/binlog/BinlogInterface.h +++ b/tddb/td/db/binlog/BinlogInterface.h @@ -63,10 +63,13 @@ class BinlogInterface { return seq_no; } - virtual uint64 erase_batch(std::vector event_ids) { + virtual uint64 erase_batch(vector event_ids) { + if (event_ids.empty()) { + return 0; + } uint64 seq_no = next_event_id(0); - for (auto id : event_ids) { - erase(id); + for (auto event_id : event_ids) { + erase(event_id); } return seq_no; } diff --git a/tddb/td/db/binlog/ConcurrentBinlog.cpp b/tddb/td/db/binlog/ConcurrentBinlog.cpp index cd6a95707..437a4bbbf 100644 --- a/tddb/td/db/binlog/ConcurrentBinlog.cpp +++ b/tddb/td/db/binlog/ConcurrentBinlog.cpp @@ -7,6 +7,7 @@ #include "td/db/binlog/ConcurrentBinlog.h" #include "td/utils/logging.h" +#include "td/utils/misc.h" #include "td/utils/OrderedEventsProcessor.h" #include "td/utils/SliceBuilder.h" #include "td/utils/Time.h" @@ -42,8 +43,9 @@ class BinlogActor final : public Actor { void erase_batch(uint64 seq_no, std::vector event_ids) { for (auto event_id : event_ids) { - auto event = BinlogEvent::create_raw(event_id, BinlogEvent::ServiceTypes::Empty, BinlogEvent::Flags::Rewrite, EmptyStorer()); - add_raw_event(seq_no, std::move(event), {}, {}); + auto event = BinlogEvent::create_raw(event_id, BinlogEvent::ServiceTypes::Empty, BinlogEvent::Flags::Rewrite, + EmptyStorer()); + add_raw_event(seq_no, std::move(event), Promise(), BinlogDebugInfo{__FILE__, __LINE__}); seq_no++; } } @@ -213,10 +215,14 @@ void ConcurrentBinlog::change_key(DbKey db_key, Promise<> promise) { send_closure(binlog_actor_, &detail::BinlogActor::change_key, std::move(db_key), std::move(promise)); } -uint64 ConcurrentBinlog::erase_batch(std::vector event_ids) { - auto shift = td::narrow_cast(event_ids.size()); +uint64 ConcurrentBinlog::erase_batch(vector event_ids) { + auto shift = narrow_cast(event_ids.size()); + if (shift == 0) { + return 0; + } auto seq_no = next_event_id(shift); send_closure(binlog_actor_, &detail::BinlogActor::erase_batch, seq_no, std::move(event_ids)); return seq_no; } + } // namespace td diff --git a/tddb/td/db/binlog/ConcurrentBinlog.h b/tddb/td/db/binlog/ConcurrentBinlog.h index 33e91b11b..cdac7d0dd 100644 --- a/tddb/td/db/binlog/ConcurrentBinlog.h +++ b/tddb/td/db/binlog/ConcurrentBinlog.h @@ -55,7 +55,8 @@ class ConcurrentBinlog final : public BinlogInterface { CSlice get_path() const { return path_; } - uint64 erase_batch(std::vector event_ids) final; + + uint64 erase_batch(vector event_ids) final; private: void init_impl(unique_ptr binlog, int scheduler_id);