Improve "Restore pts" warnings.

This commit is contained in:
levlam 2020-12-30 14:57:43 +03:00
parent f7c01e88e3
commit b1ffe39759
2 changed files with 25 additions and 21 deletions

View File

@ -6226,24 +6226,25 @@ void MessagesManager::add_pending_update(tl_object_ptr<telegram_api::Update> &&u
} }
int32 old_pts = td_->updates_manager_->get_pts(); int32 old_pts = td_->updates_manager_->get_pts();
if (new_pts < old_pts - 19999) { if (new_pts < old_pts - 99 && Slice(source) != "after get difference") {
// restore pts after delete_first_messages bool need_restore_pts = new_pts < old_pts - 19999;
LOG(ERROR) << "Restore pts after delete_first_messages from " << old_pts << " to " << new_pts auto now = Time::now();
<< " is temporarily disabled, pts_count = " << pts_count << ", update is from " << source << ": " if (now > last_pts_jump_warning_time_ + 1 && (need_restore_pts || now < last_pts_jump_warning_time_ + 5)) {
<< oneline(to_string(update)); LOG(ERROR) << "Restore pts after delete_first_messages from " << old_pts << " to " << new_pts
if (old_pts < 10000000 && update->get_id() == telegram_api::updateNewMessage::ID) { << " is disabled, pts_count = " << pts_count << ", update is from " << source << ": "
auto update_new_message = static_cast<telegram_api::updateNewMessage *>(update.get()); << oneline(to_string(update));
auto dialog_id = get_message_dialog_id(update_new_message->message_); last_pts_jump_warning_time_ = now;
dump_debug_message_op(get_dialog(dialog_id), 6);
} }
set_get_difference_timeout(0.001); if (need_restore_pts) {
set_get_difference_timeout(0.001);
/* /*
LOG(WARNING) << "Restore pts after delete_first_messages"; LOG(WARNING) << "Restore pts after delete_first_messages";
td_->updates_manager_->set_pts(new_pts - 1, "restore pts after delete_first_messages"); td_->updates_manager_->set_pts(new_pts - 1, "restore pts after delete_first_messages");
old_pts = td_->updates_manager_->get_pts(); old_pts = td_->updates_manager_->get_pts();
CHECK(old_pts == new_pts - 1); CHECK(old_pts == new_pts - 1);
*/ */
}
} }
if (new_pts <= old_pts) { if (new_pts <= old_pts) {
@ -7119,11 +7120,12 @@ void MessagesManager::add_pending_channel_update(DialogId dialog_id, tl_object_p
if (new_pts <= old_pts) { // very old or unuseful update if (new_pts <= old_pts) { // very old or unuseful update
if (new_pts < old_pts - 19999 && !is_postponed_update) { if (new_pts < old_pts - 19999 && !is_postponed_update) {
// restore channel pts after delete_first_messages // restore channel pts after delete_first_messages
LOG(ERROR) << "Restore pts in " << d->dialog_id << " from " << source << " after delete_first_messages from " auto now = Time::now();
<< old_pts << " to " << new_pts << " is temporarily disabled, pts_count = " << pts_count if (now > last_pts_jump_warning_time_ + 1) {
<< ", update is from " << source << ": " << oneline(to_string(update)); LOG(ERROR) << "Restore pts in " << d->dialog_id << " from " << source << " after delete_first_messages from "
if (old_pts < 10000000) { << old_pts << " to " << new_pts << " is temporarily disabled, pts_count = " << pts_count
dump_debug_message_op(d, 6); << ", update is from " << source << ": " << oneline(to_string(update));
last_pts_jump_warning_time_ = now;
} }
get_channel_difference(dialog_id, old_pts, true, "add_pending_channel_update old"); get_channel_difference(dialog_id, old_pts, true, "add_pending_channel_update old");
} }
@ -11788,6 +11790,7 @@ void MessagesManager::init() {
always_wait_for_mailbox(); always_wait_for_mailbox();
start_time_ = Time::now(); start_time_ = Time::now();
last_pts_jump_warning_time_ = start_time_ - 3600;
bool is_authorized = td_->auth_manager_->is_authorized(); bool is_authorized = td_->auth_manager_->is_authorized();
bool was_authorized_user = td_->auth_manager_->was_authorized() && !td_->auth_manager_->is_bot(); bool was_authorized_user = td_->auth_manager_->was_authorized() && !td_->auth_manager_->is_bot();

View File

@ -3014,6 +3014,7 @@ class MessagesManager : public Actor {
int32 accumulated_pts_count_ = 0; int32 accumulated_pts_count_ = 0;
int32 accumulated_pts_ = -1; int32 accumulated_pts_ = -1;
Timeout pts_gap_timeout_; Timeout pts_gap_timeout_;
double last_pts_jump_warning_time_ = 0;
std::unordered_map<FileId, std::pair<FullMessageId, FileId>, FileIdHash> std::unordered_map<FileId, std::pair<FullMessageId, FileId>, FileIdHash>
being_uploaded_files_; // file_id -> message, thumbnail_file_id being_uploaded_files_; // file_id -> message, thumbnail_file_id