Improve schedule_get_difference logging.

This commit is contained in:
levlam 2021-03-14 05:19:07 +03:00
parent 76dce207b3
commit 58d9f668c1

View File

@ -216,7 +216,7 @@ void UpdatesManager::fill_qts_gap(void *td) {
}
void UpdatesManager::fill_get_difference_gap(void *td) {
fill_gap(td, "rare getDifference calls");
fill_gap(td, nullptr);
}
void UpdatesManager::fill_gap(void *td, const char *source) {
@ -226,7 +226,9 @@ void UpdatesManager::fill_gap(void *td, const char *source) {
}
auto updates_manager = static_cast<Td *>(td)->updates_manager_.get();
LOG(WARNING) << "Filling gap in " << source << " by running getDifference";
if (source != nullptr) {
LOG(WARNING) << "Filling gap in " << source << " by running getDifference";
}
updates_manager->get_difference("fill_gap");
}
@ -359,7 +361,7 @@ Promise<> UpdatesManager::set_pts(int32 pts, const char *source) {
result = add_pts(pts);
if (last_get_difference_pts_ < get_pts() - FORCED_GET_DIFFERENCE_PTS_DIFF) {
last_get_difference_pts_ = get_pts();
schedule_get_difference("set_pts");
schedule_get_difference("rare pts getDifference");
}
} else if (pts < get_pts()) {
LOG(ERROR) << "Receive wrong pts = " << pts << " from " << source << ". Current pts = " << get_pts();
@ -904,8 +906,8 @@ void UpdatesManager::on_failed_get_difference(Status &&error) {
}
void UpdatesManager::schedule_get_difference(const char *source) {
VLOG(get_difference) << "Schedule getDifference from " << source;
if (!retry_timeout_.has_timeout()) {
LOG(WARNING) << "Schedule getDifference in " << retry_time_ << " seconds from " << source;
retry_timeout_.set_callback(std::move(fill_get_difference_gap));
retry_timeout_.set_callback_data(static_cast<void *>(td_));
retry_timeout_.set_timeout_in(retry_time_);
@ -913,6 +915,8 @@ void UpdatesManager::schedule_get_difference(const char *source) {
if (retry_time_ > 60) {
retry_time_ = Random::fast(60, 80);
}
} else {
VLOG(get_difference) << "Schedule getDifference from " << source;
}
}
@ -1653,7 +1657,7 @@ void UpdatesManager::add_pending_qts_update(tl_object_ptr<telegram_api::Update>
CHECK(update != nullptr);
if (qts <= 1) {
LOG(ERROR) << "Receive wrong qts " << qts << " in " << oneline(to_string(update));
schedule_get_difference("add_pending_qts_update");
schedule_get_difference("wrong qts");
promise.set_value(Unit());
return;
}
@ -1959,7 +1963,7 @@ void UpdatesManager::process_qts_update(tl_object_ptr<telegram_api::Update> &&up
LOG(DEBUG) << "Process " << to_string(update_ptr);
if (last_get_difference_qts_ < qts - FORCED_GET_DIFFERENCE_PTS_DIFF) {
if (last_get_difference_qts_ != 0) {
schedule_get_difference("process_qts_update");
schedule_get_difference("rare qts getDifference");
}
last_get_difference_qts_ = qts;
}