Add TdDb::get_binlog debug.

GitOrigin-RevId: c1a155df722fbc8901f02875eabb00e857179914
This commit is contained in:
levlam 2019-04-03 02:22:34 +03:00
parent 76b4de2413
commit 3a2af5d4b1
5 changed files with 21 additions and 14 deletions

View File

@ -1626,7 +1626,9 @@ void NotificationManager::on_notification_removed(NotificationId notification_id
return;
}
VLOG(notifications) << "Remove from binlog " << notification_id << " with logevent " << it->second;
binlog_erase(G()->td_db()->get_binlog(), it->second);
if (!is_being_destroyed_) {
binlog_erase(G()->td_db()->get_binlog("on_notification_removed"), it->second);
}
temporary_notification_logevent_ids_.erase(it);
}
@ -3170,7 +3172,7 @@ void NotificationManager::process_message_push_notification(DialogId dialog_id,
VLOG(notifications) << "Don't need message push notification for " << message_id << "/" << random_id << " from "
<< dialog_id << ": " << r_info.error();
if (logevent_id != 0) {
binlog_erase(G()->td_db()->get_binlog(), logevent_id);
binlog_erase(G()->td_db()->get_binlog("process_message_push_notification"), logevent_id);
}
if (r_info.error().code() == 406) {
promise.set_error(r_info.move_as_error());
@ -3223,7 +3225,8 @@ void NotificationManager::process_message_push_notification(DialogId dialog_id,
sender_name, date, contains_mention, is_silent,
loc_key, arg, notification_id};
auto storer = LogEventStorerImpl<AddMessagePushNotificationLogEvent>(logevent);
logevent_id = binlog_add(G()->td_db()->get_binlog(), LogEvent::HandlerType::AddMessagePushNotification, storer);
logevent_id = binlog_add(G()->td_db()->get_binlog("process_message_push_notification 2"),
LogEvent::HandlerType::AddMessagePushNotification, storer);
}
if (logevent_id != 0) {
@ -3451,6 +3454,7 @@ void NotificationManager::destroy_all_notifications() {
if (is_destroyed_) {
return;
}
is_being_destroyed_ = true;
size_t cur_pos = 0;
for (auto it = groups_.begin(); it != groups_.end() && cur_pos < max_notification_group_count_; ++it, cur_pos++) {
@ -3548,7 +3552,7 @@ void NotificationManager::on_binlog_events(vector<BinlogEvent> &&events) {
switch (event.type_) {
case LogEvent::HandlerType::AddMessagePushNotification: {
if (!G()->parameters().use_message_db || is_disabled() || max_notification_group_count_ == 0) {
binlog_erase(G()->td_db()->get_binlog(), event.id_);
binlog_erase(G()->td_db()->get_binlog("AddMessagePushNotification"), event.id_);
break;
}

View File

@ -331,6 +331,7 @@ class NotificationManager : public Actor {
SyncState contact_registered_notifications_sync_state_ = SyncState::NotSynced;
bool disable_contact_registered_notifications_ = false;
bool is_being_destroyed_ = false;
bool is_destroyed_ = false;
bool is_inited_ = false;

View File

@ -598,13 +598,14 @@ void PollManager::do_set_poll_answer(PollId poll_id, FullMessageId full_message_
auto storer = LogEventStorerImpl<SetPollAnswerLogEvent>(logevent);
if (pending_answer.generation_ == 0) {
CHECK(pending_answer.logevent_id_ == 0);
logevent_id = binlog_add(G()->td_db()->get_binlog(), LogEvent::HandlerType::SetPollAnswer, storer);
logevent_id =
binlog_add(G()->td_db()->get_binlog("do_set_poll_answer"), LogEvent::HandlerType::SetPollAnswer, storer);
LOG(INFO) << "Add set poll answer logevent " << logevent_id;
} else {
CHECK(pending_answer.logevent_id_ != 0);
logevent_id = pending_answer.logevent_id_;
auto new_logevent_id = binlog_rewrite(G()->td_db()->get_binlog(), pending_answer.logevent_id_,
LogEvent::HandlerType::SetPollAnswer, storer);
auto new_logevent_id = binlog_rewrite(G()->td_db()->get_binlog("do_set_poll_answer_2"),
pending_answer.logevent_id_, LogEvent::HandlerType::SetPollAnswer, storer);
LOG(INFO) << "Rewrite set poll answer logevent " << logevent_id << " with " << new_logevent_id;
}
}
@ -663,7 +664,7 @@ void PollManager::on_set_poll_answer(PollId poll_id, uint64 generation,
if (pending_answer.logevent_id_ != 0) {
LOG(INFO) << "Delete set poll answer logevent " << pending_answer.logevent_id_;
binlog_erase(G()->td_db()->get_binlog(), pending_answer.logevent_id_);
binlog_erase(G()->td_db()->get_binlog("on_set_poll_answer"), pending_answer.logevent_id_);
}
auto promises = std::move(pending_answer.promises_);
@ -729,7 +730,7 @@ void PollManager::do_stop_poll(PollId poll_id, FullMessageId full_message_id, ui
if (logevent_id == 0 && G()->parameters().use_message_db) {
StopPollLogEvent logevent{poll_id, full_message_id};
auto storer = LogEventStorerImpl<StopPollLogEvent>(logevent);
logevent_id = binlog_add(G()->td_db()->get_binlog(), LogEvent::HandlerType::StopPoll, storer);
logevent_id = binlog_add(G()->td_db()->get_binlog("do_stop_poll"), LogEvent::HandlerType::StopPoll, storer);
}
auto new_promise = get_erase_logevent_promise(logevent_id, std::move(promise));
@ -978,7 +979,7 @@ void PollManager::on_binlog_events(vector<BinlogEvent> &&events) {
switch (event.type_) {
case LogEvent::HandlerType::SetPollAnswer: {
if (!G()->parameters().use_message_db) {
binlog_erase(G()->td_db()->get_binlog(), event.id_);
binlog_erase(G()->td_db()->get_binlog("SetPollAnswer"), event.id_);
break;
}
@ -997,7 +998,7 @@ void PollManager::on_binlog_events(vector<BinlogEvent> &&events) {
}
case LogEvent::HandlerType::StopPoll: {
if (!G()->parameters().use_message_db) {
binlog_erase(G()->td_db()->get_binlog(), event.id_);
binlog_erase(G()->td_db()->get_binlog("StopPoll"), event.id_);
break;
}

View File

@ -8,6 +8,7 @@
#include "td/telegram/DialogDb.h"
#include "td/telegram/files/FileDb.h"
#include "td/telegram/Global.h"
#include "td/telegram/logevent/LogEvent.h"
#include "td/telegram/MessagesDb.h"
#include "td/telegram/TdParameters.h"
@ -146,8 +147,8 @@ std::shared_ptr<SqliteConnectionSafe> &TdDb::get_sqlite_connection_safe() {
return sql_connection_;
}
BinlogInterface *TdDb::get_binlog() {
CHECK(binlog_);
BinlogInterface *TdDb::get_binlog(const char *source) {
LOG_CHECK(binlog_) << G()->close_flag() << " " << source;
return binlog_.get();
}

View File

@ -70,7 +70,7 @@ class TdDb {
std::shared_ptr<FileDbInterface> get_file_db_shared();
std::shared_ptr<SqliteConnectionSafe> &get_sqlite_connection_safe();
BinlogInterface *get_binlog();
BinlogInterface *get_binlog(const char *source = "unknown");
std::shared_ptr<KeyValueSyncInterface> get_binlog_pmc_shared();
std::shared_ptr<KeyValueSyncInterface> get_config_pmc_shared();