Improve NetQueryDebug field names.

GitOrigin-RevId: 56c8c1804e9962caceda0105591cfd16446cd56c
This commit is contained in:
levlam 2020-06-10 02:03:09 +03:00
parent fcb7a51eb0
commit 1e6bdbb7a5
3 changed files with 27 additions and 26 deletions

View File

@ -82,13 +82,14 @@ void dump_pending_network_queries() {
was_gap = false;
}
const NetQueryDebug &debug = cur->get_data_unsafe();
LOG(WARNING) << tag("id", debug.my_id_) << *static_cast<const NetQuery *>(cur)
<< /*tag("total_flood", format::as_time(debug.total_timeout_)) <<*/ " "
const NetQuery &nq = *static_cast<const NetQuery *>(cur);
LOG(WARNING) << tag("user id", debug.my_id_) << nq << tag("total flood", format::as_time(nq.total_timeout))
<< tag("since start", format::as_time(Time::now_cached() - debug.start_timestamp_))
<< tag("state", debug.debug_str_)
<< tag("since state", format::as_time(Time::now_cached() - debug.debug_timestamp_))
<< tag("resend_cnt", debug.debug_resend_cnt_) << tag("fail_cnt", debug.debug_send_failed_cnt_)
<< tag("ack", debug.debug_ack_) << tag("unknown", debug.debug_unknown_);
<< tag("state", debug.state_)
<< tag("in this state", format::as_time(Time::now_cached() - debug.state_timestamp_))
<< tag("state changed", debug.state_change_count_) << tag("resend count", debug.resend_count_)
<< tag("fail count", debug.send_failed_count_) << tag("ack state", debug.ack_state_)
<< tag("unknown", debug.unknown_state_);
} else {
was_gap = true;
}

View File

@ -43,13 +43,13 @@ class NetQueryCallback : public Actor {
struct NetQueryDebug {
double start_timestamp_ = 0;
int32 my_id_ = 0;
int32 debug_resend_cnt_ = 0;
string debug_str_ = "empty";
double debug_timestamp_ = 0;
int32 debug_cnt_ = 0;
int32 debug_send_failed_cnt_ = 0;
int debug_ack_ = 0;
bool debug_unknown_ = false;
int32 resend_count_ = 0;
string state_ = "empty";
double state_timestamp_ = 0;
int32 state_change_count_ = 0;
int32 send_failed_count_ = 0;
int ack_state_ = 0;
bool unknown_state_ = false;
};
class NetQuery : public TsListNode<NetQueryDebug> {
@ -90,7 +90,7 @@ class NetQuery : public TsListNode<NetQueryDebug> {
VLOG(net_query) << "Resend" << *this;
{
auto guard = lock();
get_data_unsafe().debug_resend_cnt_++;
get_data_unsafe().resend_count_++;
}
dc_id_ = new_dc_id;
status_ = Status::OK();
@ -228,7 +228,7 @@ class NetQuery : public TsListNode<NetQueryDebug> {
void clear() {
if (!is_ready()) {
auto guard = lock();
LOG(ERROR) << "Destroy not ready query " << *this << " " << tag("debug", get_data_unsafe().debug_str_);
LOG(ERROR) << "Destroy not ready query " << *this << " " << tag("state", get_data_unsafe().state_);
}
// TODO: CHECK if net_query is lost here
cancel_slot_.close();
@ -245,19 +245,19 @@ class NetQuery : public TsListNode<NetQueryDebug> {
void debug_send_failed() {
auto guard = lock();
get_data_unsafe().debug_send_failed_cnt_++;
get_data_unsafe().send_failed_count_++;
}
void debug(string str, bool may_be_lost = false) {
void debug(string state, bool may_be_lost = false) {
may_be_lost_ = may_be_lost;
{
auto guard = lock();
auto &data = get_data_unsafe();
data.debug_str_ = str;
data.debug_timestamp_ = Time::now();
data.debug_cnt_++;
data.state_ = state;
data.state_timestamp_ = Time::now();
data.state_change_count_++;
}
VLOG(net_query) << *this << " " << tag("debug", str);
VLOG(net_query) << *this << " " << tag("state", state);
}
void set_callback(ActorShared<NetQueryCallback> callback) {

View File

@ -619,7 +619,7 @@ void Session::on_message_ack_impl_inner(uint64 id, int32 type, bool in_container
it->second.ack = true;
{
auto lock = it->second.query->lock();
it->second.query->get_data_unsafe().debug_ack_ |= type;
it->second.query->get_data_unsafe().ack_state_ |= type;
}
it->second.query->quick_ack_promise_.set_value(Unit());
if (!in_container) {
@ -657,7 +657,7 @@ void Session::cleanup_container(uint64 message_id, Query *query) {
void Session::mark_as_known(uint64 id, Query *query) {
{
auto lock = query->query->lock();
query->query->get_data_unsafe().debug_unknown_ = false;
query->query->get_data_unsafe().unknown_state_ = false;
}
if (!query->unknown) {
return;
@ -673,7 +673,7 @@ void Session::mark_as_known(uint64 id, Query *query) {
void Session::mark_as_unknown(uint64 id, Query *query) {
{
auto lock = query->query->lock();
query->query->get_data_unsafe().debug_unknown_ = true;
query->query->get_data_unsafe().unknown_state_ = true;
}
if (query->unknown) {
return;
@ -941,8 +941,8 @@ void Session::connection_send_query(ConnectionInfo *info, NetQueryPtr &&net_quer
LOG_CHECK(sent_queries_.find(message_id) == sent_queries_.end()) << message_id;
{
auto lock = net_query->lock();
net_query->get_data_unsafe().debug_unknown_ = false;
net_query->get_data_unsafe().debug_ack_ = 0;
net_query->get_data_unsafe().unknown_state_ = false;
net_query->get_data_unsafe().ack_state_ = 0;
}
if (!net_query->cancel_slot_.empty()) {
LOG(DEBUG) << "Set event for net_query cancellation " << tag("message_id", format::as_hex(message_id));