Skip to content

Commit 7e1bab9

Browse files
committed
Metrics for origin close
1 parent 6f564de commit 7e1bab9

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
}
@@ -2983,6 +2986,13 @@ HttpSM::tunnel_handler_server(int event, HttpTunnelProducer *p)
29832986
plugin_tunnel_type == HTTP_NO_PLUGIN_TUNNEL && t_state.txn_conf->keep_alive_enabled_out == 1) {
29842987
close_connection = false;
29852988
} else {
2989+
if (t_state.current.server->keep_alive != HTTP_KEEPALIVE) {
2990+
HTTP_INCREMENT_DYN_STAT(http_origin_shutdown_tunnel_server_no_keep_alive);
2991+
} else if (server_entry->eos == true) {
2992+
HTTP_INCREMENT_DYN_STAT(http_origin_shutdown_tunnel_server_eos);
2993+
} else {
2994+
HTTP_INCREMENT_DYN_STAT(http_origin_shutdown_tunnel_server_plugin_tunnel);
2995+
}
29862996
close_connection = true;
29872997
}
29882998

@@ -3011,6 +3021,7 @@ HttpSM::tunnel_handler_server(int event, HttpTunnelProducer *p)
30113021
break;
30123022
}
30133023

3024+
HTTP_INCREMENT_DYN_STAT(http_origin_shutdown_tunnel_server);
30143025
close_connection = true;
30153026

30163027
ink_assert(p->vc_type == HT_HTTP_SERVER);
@@ -3079,7 +3090,8 @@ HttpSM::tunnel_handler_server(int event, HttpTunnelProducer *p)
30793090
p->read_success = true;
30803091
t_state.current.server->state = HttpTransact::TRANSACTION_COMPLETE;
30813092
t_state.current.server->abort = HttpTransact::DIDNOT_ABORT;
3082-
close_connection = true;
3093+
HTTP_INCREMENT_DYN_STAT(http_origin_shutdown_tunnel_server_detach);
3094+
close_connection = true;
30833095
break;
30843096

30853097
case VC_EVENT_READ_READY:
@@ -3939,6 +3951,7 @@ HttpSM::tunnel_handler_transform_read(int event, HttpTunnelProducer *p)
39393951
// transform hasn't detached yet. If it is still alive,
39403952
// don't close the transform vc
39413953
if (p->self_consumer->alive == false) {
3954+
HTTP_INCREMENT_DYN_STAT(http_origin_shutdown_tunnel_transform_read);
39423955
p->vc->do_io_close();
39433956
}
39443957
p->handler_state = HTTP_SM_TRANSFORM_CLOSED;
@@ -5438,6 +5451,23 @@ HttpSM::release_server_session(bool serve_from_cache)
54385451
ua_txn->attach_server_session(server_session, false);
54395452
}
54405453
} else {
5454+
if (TS_SERVER_SESSION_SHARING_MATCH_NONE == t_state.txn_conf->server_session_sharing_match) {
5455+
HTTP_INCREMENT_DYN_STAT(http_origin_shutdown_release_no_sharing);
5456+
} else if (t_state.current.server == nullptr) {
5457+
HTTP_INCREMENT_DYN_STAT(http_origin_shutdown_release_no_server);
5458+
} else if (t_state.current.server->keep_alive != HTTP_KEEPALIVE) {
5459+
HTTP_INCREMENT_DYN_STAT(http_origin_shutdown_release_no_keep_alive);
5460+
} else if (!t_state.hdr_info.server_response.valid()) {
5461+
HTTP_INCREMENT_DYN_STAT(http_origin_shutdown_release_invalid_response);
5462+
} else if (!t_state.hdr_info.server_request.valid()) {
5463+
HTTP_INCREMENT_DYN_STAT(http_origin_shutdown_release_invalid_request);
5464+
} else if (t_state.hdr_info.server_response.status_get() != HTTP_STATUS_NOT_MODIFIED &&
5465+
(t_state.hdr_info.server_request.method_get_wksidx() != HTTP_WKSIDX_HEAD ||
5466+
t_state.www_auth_content == HttpTransact::CACHE_AUTH_NONE)) {
5467+
HTTP_INCREMENT_DYN_STAT(http_origin_shutdown_release_modified);
5468+
} else {
5469+
HTTP_INCREMENT_DYN_STAT(http_origin_shutdown_release_misc);
5470+
}
54415471
server_session->do_io_close();
54425472
}
54435473

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)