Add temporary ignoring of duplicate user/channel log events.

GitOrigin-RevId: ecd17421d9f2c3591ce4a4d84970949954f8496e
This commit is contained in:
levlam 2018-08-01 17:10:07 +03:00
parent 986652a1ae
commit c01dcf9a99

View File

@ -5177,7 +5177,12 @@ void ContactsManager::on_binlog_user_event(BinlogEvent &&event) {
auto user_id = log_event.user_id;
LOG(INFO) << "Add " << user_id << " from binlog";
User *u = add_user(user_id, "on_binlog_user_event");
CHECK(u->first_name.empty()) << user_id << " " << u->debug_source;
if (!(u->first_name.empty() && u->last_name.empty()) && Slice(u->debug_source) == Slice("on_binlog_user_event")) {
LOG(ERROR) << "Skip adding already added " << user_id;
binlog_erase(G()->td_db()->get_binlog(), event.id_);
return; // TODO fix bug in Binlog and remove that fix
}
CHECK(u->first_name.empty() && u->last_name.empty()) << user_id << " " << u->debug_source;
*u = std::move(log_event.u); // users come from binlog before all other events, so just add them
u->logevent_id = event.id_;
@ -5649,6 +5654,11 @@ void ContactsManager::on_binlog_channel_event(BinlogEvent &&event) {
auto channel_id = log_event.channel_id;
LOG(INFO) << "Add " << channel_id << " from binlog";
Channel *c = add_channel(channel_id, "on_binlog_channel_event");
if (!c->status.is_banned() && Slice(c->debug_source) == Slice("on_binlog_channel_event")) {
LOG(ERROR) << "Skip adding already added " << channel_id;
binlog_erase(G()->td_db()->get_binlog(), event.id_);
return; // TODO fix bug in Binlog and remove that fix
}
CHECK(c->status.is_banned()) << channel_id << " " << c->debug_source;
*c = std::move(log_event.c); // channels come from binlog before all other events, so just add them