Skip to content

Commit 3e4b88e

Browse files
shinrichzwoop
authored andcommitted
Metrics for origin close (#6873)
(cherry picked from commit 613576f)
1 parent 416cb64 commit 3e4b88e

File tree

7 files changed

+150
-1
lines changed

7 files changed

+150
-1
lines changed

doc/admin-guide/monitoring/statistics/core/origin.en.rst

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,63 @@ Origin Server
7878
:type: derivative
7979
:units: bytes
8080

81+
.. ts:stat:: global proxy.process.http.origin_shutdown.pool_lock_contention integer
82+
:type counter
83+
:units bytes
84+
85+
.. ts:stat:: global proxy.process.http.origin_shutdown.migration_failure integer
86+
:type counter
87+
:units bytes
88+
89+
.. ts:stat:: global proxy.process.http.origin_shutdown.tunnel_server integer
90+
:type counter
91+
:units bytes
92+
93+
.. ts:stat:: global proxy.process.http.origin_shutdown.tunnel_server_no_keep_alive integer
94+
:type counter
95+
:units bytes
96+
97+
.. ts:stat:: global proxy.process.http.origin_shutdown.tunnel_server_eos integer
98+
:type counter
99+
:units bytes
100+
101+
.. ts:stat:: global proxy.process.http.origin_shutdown.tunnel_server_plugin_tunnel integer
102+
:type counter
103+
:units bytes
104+
105+
.. ts:stat:: global proxy.process.http.origin_shutdown.tunnel_transform_read integer
106+
:type counter
107+
:units bytes
108+
109+
.. ts:stat:: global proxy.process.http.origin_shutdown.release_no_sharing integer
110+
:type counter
111+
:units bytes
112+
113+
.. ts:stat:: global proxy.process.http.origin_shutdown.release_no_keep_alive integer
114+
:type counter
115+
:units bytes
116+
117+
.. ts:stat:: global proxy.process.http.origin_shutdown.release_invalid_repsonse integer
118+
:type counter
119+
:units bytes
120+
121+
.. ts:stat:: global proxy.process.http.origin_shutdown.release_invalid_request integer
122+
:type counter
123+
:units bytes
124+
125+
.. ts:stat:: global proxy.process.http.origin_shutdown.release_modified integer
126+
:type counter
127+
:units bytes
128+
129+
.. ts:stat:: global proxy.process.http.origin_shutdown.release_misc integer
130+
:type counter
131+
:units bytes
132+
133+
.. ts:stat:: global proxy.process.http.origin_shutdown.cleanup_entry integer
134+
:type counter
135+
:units bytes
136+
137+
.. ts:stat:: global proxy.process.http.origin_shutdown.tunnel_abort integer
138+
:type counter
139+
:units bytes
81140

proxy/http/Http1ServerSession.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ Http1ServerSession::release()
196196
// due to lock contention
197197
// FIX: should retry instead of closing
198198
this->do_io_close();
199+
HTTP_INCREMENT_DYN_STAT(http_origin_shutdown_pool_lock_contention);
199200
} else {
200201
// The session was successfully put into the session
201202
// manager and it will manage it

proxy/http/HttpConfig.cc

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,44 @@ register_stat_callbacks()
350350
RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.total_parent_marked_down_count", RECD_COUNTER, RECP_PERSISTENT,
351351
(int)http_total_parent_marked_down_count, RecRawStatSyncCount);
352352

353+
// Stats to track causes of ATS initiated origin shutdowns
354+
RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin_shutdown.pool_lock_contention", RECD_INT,
355+
RECP_NON_PERSISTENT, (int)http_origin_shutdown_pool_lock_contention, RecRawStatSyncCount);
356+
RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin_shutdown.migration_failure", RECD_INT, RECP_NON_PERSISTENT,
357+
(int)http_origin_shutdown_migration_failure, RecRawStatSyncCount);
358+
RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin_shutdown.tunnel_server", RECD_INT, RECP_NON_PERSISTENT,
359+
(int)http_origin_shutdown_tunnel_server, RecRawStatSyncCount);
360+
RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin_shutdown.tunnel_server_no_keep_alive", RECD_INT,
361+
RECP_NON_PERSISTENT, (int)http_origin_shutdown_tunnel_server_no_keep_alive, RecRawStatSyncCount);
362+
RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin_shutdown.tunnel_server_eos", RECD_INT, RECP_NON_PERSISTENT,
363+
(int)http_origin_shutdown_tunnel_server_eos, RecRawStatSyncCount);
364+
RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin_shutdown.tunnel_server_plugin_tunnel", RECD_INT,
365+
RECP_NON_PERSISTENT, (int)http_origin_shutdown_tunnel_server_plugin_tunnel, RecRawStatSyncCount);
366+
RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin_shutdown.tunnel_server_detach", RECD_INT,
367+
RECP_NON_PERSISTENT, (int)http_origin_shutdown_tunnel_server_detach, RecRawStatSyncCount);
368+
RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin_shutdown.tunnel_client", RECD_INT, RECP_NON_PERSISTENT,
369+
(int)http_origin_shutdown_tunnel_client, RecRawStatSyncCount);
370+
RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin_shutdown.tunnel_transform_read", RECD_INT,
371+
RECP_NON_PERSISTENT, (int)http_origin_shutdown_tunnel_transform_read, RecRawStatSyncCount);
372+
RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin_shutdown.release_no_sharing", RECD_INT, RECP_NON_PERSISTENT,
373+
(int)http_origin_shutdown_release_no_sharing, RecRawStatSyncCount);
374+
RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin_shutdown.release_no_server", RECD_INT, RECP_NON_PERSISTENT,
375+
(int)http_origin_shutdown_release_no_server, RecRawStatSyncCount);
376+
RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin_shutdown.release_no_keep_alive", RECD_INT,
377+
RECP_NON_PERSISTENT, (int)http_origin_shutdown_release_no_keep_alive, RecRawStatSyncCount);
378+
RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin_shutdown.release_invalid_response", RECD_INT,
379+
RECP_NON_PERSISTENT, (int)http_origin_shutdown_release_invalid_response, RecRawStatSyncCount);
380+
RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin_shutdown.release_invalid_request", RECD_INT,
381+
RECP_NON_PERSISTENT, (int)http_origin_shutdown_release_invalid_request, RecRawStatSyncCount);
382+
RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin_shutdown.release_modified", RECD_INT, RECP_NON_PERSISTENT,
383+
(int)http_origin_shutdown_release_modified, RecRawStatSyncCount);
384+
RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin_shutdown.release_misc", RECD_INT, RECP_NON_PERSISTENT,
385+
(int)http_origin_shutdown_release_misc, RecRawStatSyncCount);
386+
RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin_shutdown.cleanup_entry", RECD_INT, RECP_NON_PERSISTENT,
387+
(int)http_origin_shutdown_cleanup_entry, RecRawStatSyncCount);
388+
RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin_shutdown.tunnel_abort", RECD_INT, RECP_NON_PERSISTENT,
389+
(int)http_origin_shutdown_tunnel_abort, RecRawStatSyncCount);
390+
353391
// Upstream current connections stats
354392
RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.current_parent_proxy_connections", RECD_INT, RECP_NON_PERSISTENT,
355393
(int)http_current_parent_proxy_connections_stat, RecRawStatSyncSum);

proxy/http/HttpConfig.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,25 @@ enum {
331331
http_origin_connect_adjust_thread_stat,
332332
http_cache_open_write_adjust_thread_stat,
333333

334+
http_origin_shutdown_pool_lock_contention,
335+
http_origin_shutdown_migration_failure,
336+
http_origin_shutdown_tunnel_server,
337+
http_origin_shutdown_tunnel_server_no_keep_alive,
338+
http_origin_shutdown_tunnel_server_eos,
339+
http_origin_shutdown_tunnel_server_plugin_tunnel,
340+
http_origin_shutdown_tunnel_server_detach,
341+
http_origin_shutdown_tunnel_client,
342+
http_origin_shutdown_tunnel_transform_read,
343+
http_origin_shutdown_release_no_sharing,
344+
http_origin_shutdown_release_no_server,
345+
http_origin_shutdown_release_no_keep_alive,
346+
http_origin_shutdown_release_invalid_response,
347+
http_origin_shutdown_release_invalid_request,
348+
http_origin_shutdown_release_modified,
349+
http_origin_shutdown_release_misc,
350+
http_origin_shutdown_cleanup_entry,
351+
http_origin_shutdown_tunnel_abort,
352+
334353
http_stat_count
335354
};
336355

proxy/http/HttpSM.cc

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,9 @@ HttpVCTable::cleanup_entry(HttpVCTableEntry *e)
229229
break;
230230
}
231231

232+
if (e->vc_type == HTTP_SERVER_VC) {
233+
HTTP_INCREMENT_DYN_STAT(http_origin_shutdown_cleanup_entry);
234+
}
232235
e->vc->do_io_close();
233236
e->vc = nullptr;
234237
}
@@ -2940,6 +2943,13 @@ HttpSM::tunnel_handler_server(int event, HttpTunnelProducer *p)
29402943
plugin_tunnel_type == HTTP_NO_PLUGIN_TUNNEL && t_state.txn_conf->keep_alive_enabled_out == 1) {
29412944
close_connection = false;
29422945
} else {
2946+
if (t_state.current.server->keep_alive != HTTP_KEEPALIVE) {
2947+
HTTP_INCREMENT_DYN_STAT(http_origin_shutdown_tunnel_server_no_keep_alive);
2948+
} else if (server_entry->eos == true) {
2949+
HTTP_INCREMENT_DYN_STAT(http_origin_shutdown_tunnel_server_eos);
2950+
} else {
2951+
HTTP_INCREMENT_DYN_STAT(http_origin_shutdown_tunnel_server_plugin_tunnel);
2952+
}
29432953
close_connection = true;
29442954
}
29452955

@@ -2968,6 +2978,7 @@ HttpSM::tunnel_handler_server(int event, HttpTunnelProducer *p)
29682978
break;
29692979
}
29702980

2981+
HTTP_INCREMENT_DYN_STAT(http_origin_shutdown_tunnel_server);
29712982
close_connection = true;
29722983

29732984
ink_assert(p->vc_type == HT_HTTP_SERVER);
@@ -3036,7 +3047,8 @@ HttpSM::tunnel_handler_server(int event, HttpTunnelProducer *p)
30363047
p->read_success = true;
30373048
t_state.current.server->state = HttpTransact::TRANSACTION_COMPLETE;
30383049
t_state.current.server->abort = HttpTransact::DIDNOT_ABORT;
3039-
close_connection = true;
3050+
HTTP_INCREMENT_DYN_STAT(http_origin_shutdown_tunnel_server_detach);
3051+
close_connection = true;
30403052
break;
30413053

30423054
case VC_EVENT_READ_READY:
@@ -3899,6 +3911,7 @@ HttpSM::tunnel_handler_transform_read(int event, HttpTunnelProducer *p)
38993911
// transform hasn't detached yet. If it is still alive,
39003912
// don't close the transform vc
39013913
if (p->self_consumer->alive == false) {
3914+
HTTP_INCREMENT_DYN_STAT(http_origin_shutdown_tunnel_transform_read);
39023915
p->vc->do_io_close();
39033916
}
39043917
p->handler_state = HTTP_SM_TRANSFORM_CLOSED;
@@ -5398,6 +5411,23 @@ HttpSM::release_server_session(bool serve_from_cache)
53985411
ua_txn->attach_server_session(server_session, false);
53995412
}
54005413
} else {
5414+
if (TS_SERVER_SESSION_SHARING_MATCH_NONE == t_state.txn_conf->server_session_sharing_match) {
5415+
HTTP_INCREMENT_DYN_STAT(http_origin_shutdown_release_no_sharing);
5416+
} else if (t_state.current.server == nullptr) {
5417+
HTTP_INCREMENT_DYN_STAT(http_origin_shutdown_release_no_server);
5418+
} else if (t_state.current.server->keep_alive != HTTP_KEEPALIVE) {
5419+
HTTP_INCREMENT_DYN_STAT(http_origin_shutdown_release_no_keep_alive);
5420+
} else if (!t_state.hdr_info.server_response.valid()) {
5421+
HTTP_INCREMENT_DYN_STAT(http_origin_shutdown_release_invalid_response);
5422+
} else if (!t_state.hdr_info.server_request.valid()) {
5423+
HTTP_INCREMENT_DYN_STAT(http_origin_shutdown_release_invalid_request);
5424+
} else if (t_state.hdr_info.server_response.status_get() != HTTP_STATUS_NOT_MODIFIED &&
5425+
(t_state.hdr_info.server_request.method_get_wksidx() != HTTP_WKSIDX_HEAD ||
5426+
t_state.www_auth_content == HttpTransact::CACHE_AUTH_NONE)) {
5427+
HTTP_INCREMENT_DYN_STAT(http_origin_shutdown_release_modified);
5428+
} else {
5429+
HTTP_INCREMENT_DYN_STAT(http_origin_shutdown_release_misc);
5430+
}
54015431
server_session->do_io_close();
54025432
}
54035433

proxy/http/HttpSessionManager.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ HttpSessionManager::acquire_session(Continuation * /* cont ATS_UNUSED */, sockad
401401
ink_assert(new_vc == nullptr || new_vc->nh != nullptr);
402402
if (!new_vc) {
403403
// Close out to_return, we were't able to get a connection
404+
HTTP_INCREMENT_DYN_STAT(http_origin_shutdown_migration_failure);
404405
to_return->do_io_close();
405406
to_return = nullptr;
406407
retval = HSM_NOT_FOUND;

proxy/http/HttpTunnel.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1419,6 +1419,7 @@ HttpTunnel::chain_abort_all(HttpTunnelProducer *p)
14191419
}
14201420
p->read_vio = nullptr;
14211421
p->vc->do_io_close(EHTTP_ERROR);
1422+
HTTP_INCREMENT_DYN_STAT(http_origin_shutdown_tunnel_abort);
14221423
update_stats_after_abort(p->vc_type);
14231424
}
14241425
}

0 commit comments

Comments
 (0)