Improve get_binlog debug.

GitOrigin-RevId: 8c4480d6f60e792d8bd8a76001d0d9d931c743f6
This commit is contained in:
levlam 2019-04-03 12:26:20 +03:00
parent ad9ecdc3f0
commit 28717876ad
4 changed files with 15 additions and 16 deletions

View File

@ -1627,7 +1627,7 @@ void NotificationManager::on_notification_removed(NotificationId notification_id
}
VLOG(notifications) << "Remove from binlog " << notification_id << " with logevent " << it->second;
if (!is_being_destroyed_) {
binlog_erase(G()->td_db()->get_binlog("on_notification_removed"), it->second);
binlog_erase(G()->td_db()->get_binlog(), it->second);
}
temporary_notification_logevent_ids_.erase(it);
}
@ -3172,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("process_message_push_notification"), logevent_id);
binlog_erase(G()->td_db()->get_binlog(), logevent_id);
}
if (r_info.error().code() == 406) {
promise.set_error(r_info.move_as_error());
@ -3225,8 +3225,7 @@ 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("process_message_push_notification 2"),
LogEvent::HandlerType::AddMessagePushNotification, storer);
logevent_id = binlog_add(G()->td_db()->get_binlog(), LogEvent::HandlerType::AddMessagePushNotification, storer);
}
if (logevent_id != 0) {
@ -3552,7 +3551,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("AddMessagePushNotification"), event.id_);
binlog_erase(G()->td_db()->get_binlog(), event.id_);
break;
}

View File

@ -598,14 +598,13 @@ 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("do_set_poll_answer"), LogEvent::HandlerType::SetPollAnswer, storer);
logevent_id = binlog_add(G()->td_db()->get_binlog(), 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("do_set_poll_answer_2"),
pending_answer.logevent_id_, LogEvent::HandlerType::SetPollAnswer, storer);
auto new_logevent_id = binlog_rewrite(G()->td_db()->get_binlog(), pending_answer.logevent_id_,
LogEvent::HandlerType::SetPollAnswer, storer);
LOG(INFO) << "Rewrite set poll answer logevent " << logevent_id << " with " << new_logevent_id;
}
}
@ -664,7 +663,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("on_set_poll_answer"), pending_answer.logevent_id_);
binlog_erase(G()->td_db()->get_binlog(), pending_answer.logevent_id_);
}
auto promises = std::move(pending_answer.promises_);
@ -730,7 +729,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("do_stop_poll"), LogEvent::HandlerType::StopPoll, storer);
logevent_id = binlog_add(G()->td_db()->get_binlog(), LogEvent::HandlerType::StopPoll, storer);
}
auto new_promise = get_erase_logevent_promise(logevent_id, std::move(promise));
@ -979,7 +978,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("SetPollAnswer"), event.id_);
binlog_erase(G()->td_db()->get_binlog(), event.id_);
break;
}
@ -998,7 +997,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("StopPoll"), event.id_);
binlog_erase(G()->td_db()->get_binlog(), event.id_);
break;
}

View File

@ -147,8 +147,8 @@ std::shared_ptr<SqliteConnectionSafe> &TdDb::get_sqlite_connection_safe() {
return sql_connection_;
}
BinlogInterface *TdDb::get_binlog(const char *source) {
LOG_CHECK(binlog_) << G()->close_flag() << " " << source;
BinlogInterface *TdDb::get_binlog_impl(const char *file, int line) {
LOG_CHECK(binlog_) << G()->close_flag() << " " << file << " " << line;
return binlog_.get();
}

View File

@ -70,7 +70,8 @@ class TdDb {
std::shared_ptr<FileDbInterface> get_file_db_shared();
std::shared_ptr<SqliteConnectionSafe> &get_sqlite_connection_safe();
BinlogInterface *get_binlog(const char *source = "unknown");
#define get_binlog() get_binlog_impl(__FILE__, __LINE__)
BinlogInterface *get_binlog_impl(const char *file, int line);
std::shared_ptr<KeyValueSyncInterface> get_binlog_pmc_shared();
std::shared_ptr<KeyValueSyncInterface> get_config_pmc_shared();