Improve warning messages.

This commit is contained in:
levlam 2021-01-15 16:54:14 +03:00
parent fcdb824f86
commit d9c247e5ed
4 changed files with 13 additions and 15 deletions

View File

@ -21,7 +21,6 @@
#include "td/utils/logging.h"
#include "td/utils/misc.h"
#include "td/utils/PathView.h"
#include "td/utils/port/Clocks.h"
#include "td/utils/port/path.h"
#include "td/utils/port/Stat.h"
#include "td/utils/Random.h"
@ -3242,7 +3241,7 @@ void Client::start_up() {
next_set_webhook_logging_time_ = start_time_;
next_webhook_is_not_modified_warning_time_ = start_time_;
previous_get_updates_start_time_ = start_time_ - 100;
previous_get_updates_finish_time_ = start_time_ - 100;
next_get_updates_conflict_time_ = start_time_ - 100;
sticker_set_names_[GREAT_MINDS_SET_ID] = GREAT_MINDS_SET_NAME.str();
@ -7592,9 +7591,9 @@ void Client::abort_long_poll(bool from_set_webhook) {
void Client::fail_query_conflict(Slice message, PromisedQueryPtr &&query) {
auto now = td::Time::now_cached();
if (now >= previous_get_updates_finish_time_) {
if (now >= next_get_updates_conflict_time_) {
fail_query(409, message, std::move(query));
previous_get_updates_finish_time_ = now + 3.0;
next_get_updates_conflict_time_ = now + 3.0;
} else {
td::create_actor<td::SleepActor>(
"FailQueryConflictSleepActor", 3.0,
@ -7686,7 +7685,8 @@ void Client::do_get_updates(int32 offset, int32 limit, int32 timeout, PromisedQu
}
if (need_warning) {
LOG(WARNING) << "Found " << updates.size() << " updates out of " << total_size << " + " << updates.size()
<< " after last getUpdates call at " << previous_get_updates_finish_date_;
<< " after last getUpdates call " << (td::Time::now() - previous_get_updates_finish_time_)
<< " seconds ago";
} else {
LOG(DEBUG) << "Found " << updates.size() << " updates out of " << total_size << " from " << from;
}
@ -7702,7 +7702,7 @@ void Client::do_get_updates(int32 offset, int32 limit, int32 timeout, PromisedQu
long_poll_slot_.set_timeout_at(long_poll_hard_timeout_);
return;
}
previous_get_updates_finish_date_ = td::Clocks::system(); // local time to output it to the log
previous_get_updates_finish_time_ = td::Time::now();
next_bot_updates_warning_time_ = td::Time::now() + BOT_UPDATES_WARNING_DELAY;
if (total_size == updates.size() && was_bot_updates_warning_) {
send_request(make_object<td_api::setBotUpdatesStatus>(0, ""), std::make_unique<TdOnOkCallback>());

View File

@ -922,8 +922,8 @@ class Client : public WebhookActor::Callback {
int32 previous_get_updates_offset_ = -1;
double previous_get_updates_start_time_ = 0;
double previous_get_updates_finish_date_ = 0;
double previous_get_updates_finish_time_ = 0;
double next_get_updates_conflict_time_ = 0;
td::uint64 webhook_generation_ = 1;

View File

@ -8,8 +8,6 @@
#include "telegram-bot-api/ClientParameters.h"
#include "td/db/TQueue.h"
#include "td/net/GetHostByNameActor.h"
#include "td/net/HttpHeaderCreator.h"
#include "td/net/HttpProxy.h"
@ -26,7 +24,6 @@
#include "td/utils/JsonBuilder.h"
#include "td/utils/logging.h"
#include "td/utils/misc.h"
#include "td/utils/port/Clocks.h"
#include "td/utils/port/IPAddress.h"
#include "td/utils/port/SocketFd.h"
#include "td/utils/Random.h"
@ -419,9 +416,10 @@ void WebhookActor::load_updates() {
}
}
if (need_warning) {
LOG(WARNING) << "Loaded " << updates.size() << " updates out of " << total_size << ". Have total of "
<< update_map_.size() << " loaded in " << queues_.size() << " queues after last error \""
<< last_error_message_ << "\" at " << last_error_date_;
LOG(WARNING) << "Loaded " << updates.size() << " updates out of " << total_size << ". Have " << update_map_.size()
<< " updates loaded in " << queue_updates_.size() << " queues after last error \""
<< last_error_message_ << "\" " << (last_error_time_ == 0 ? -1 : td::Time::now() - last_error_time_)
<< " seconds ago";
}
if (updates.size() == total_size && last_update_was_successful_) {
@ -741,7 +739,7 @@ void WebhookActor::on_connection_error(td::Status error) {
void WebhookActor::on_webhook_error(td::Slice error) {
if (was_checked_) {
send_closure(callback_, &Callback::webhook_error, td::Status::Error(error));
last_error_date_ = td::Clocks::system(); // local time to output it to the log
last_error_time_ = td::Time::now();
last_error_message_ = error.str();
}
}

View File

@ -79,7 +79,7 @@ class WebhookActor : public td::HttpOutboundConnection::Callback {
td::string cert_path_;
std::shared_ptr<const ClientParameters> parameters_;
double last_error_date_ = 0;
double last_error_time_ = 0;
td::string last_error_message_ = "<none>";
bool fix_ip_address_ = false;