More metrics related to connectin pool #703

Metrics introduced:
* ConnPool_get_conn_failure : connection pool cannot provide any connection
* ConnPool_get_conn_immediate : connection is provided from per-thread cache
* ConnPool_get_conn_success : the session is able to get a connection, either from per-thread cache or connection pool
pull/710/head
René Cannaò 10 years ago
parent ea086d8572
commit 505d4acce3

@ -171,6 +171,9 @@ class MySQL_Thread
unsigned long long mysql_backend_buffers_bytes;
unsigned long long mysql_frontend_buffers_bytes;
unsigned long long mysql_session_internal_bytes;
unsigned long long ConnPool_get_conn_immediate;
unsigned long long ConnPool_get_conn_success;
unsigned long long ConnPool_get_conn_failure;
unsigned int active_transactions;
} status_variables;
@ -368,6 +371,9 @@ class MySQL_Threads_Handler
unsigned long long get_mysql_backend_buffers_bytes();
unsigned long long get_mysql_frontend_buffers_bytes();
unsigned long long get_mysql_session_internal_bytes();
unsigned long long get_ConnPool_get_conn_immediate();
unsigned long long get_ConnPool_get_conn_success();
unsigned long long get_ConnPool_get_conn_failure();
iface_info *MLM_find_iface_from_fd(int fd) {
return MLM->find_iface_from_fd(fd);
}

@ -2170,9 +2170,14 @@ void MySQL_Session::handler___client_DSS_QUERY_SENT___server_DSS_NOT_INITIALIZED
mc=thread->get_MyConn_local(mybe->hostgroup_id); // experimental , #644
if (mc==NULL) {
mc=MyHGM->get_MyConn_from_pool(mybe->hostgroup_id);
} else {
thread->status_variables.ConnPool_get_conn_immediate++;
}
if (mc) {
mybe->server_myds->attach_connection(mc);
thread->status_variables.ConnPool_get_conn_success++;
} else {
thread->status_variables.ConnPool_get_conn_failure++;
}
// }
proxy_debug(PROXY_DEBUG_MYSQL_CONNECTION, 5, "Sess=%p -- server_myds=%p -- MySQL_Connection %p\n", this, mybe->server_myds, mybe->server_myds->myconn);

@ -2178,6 +2178,9 @@ MySQL_Thread::MySQL_Thread() {
status_variables.mysql_backend_buffers_bytes=0;
status_variables.mysql_frontend_buffers_bytes=0;
status_variables.mysql_session_internal_bytes=0;
status_variables.ConnPool_get_conn_immediate=0;
status_variables.ConnPool_get_conn_success=0;
status_variables.ConnPool_get_conn_failure=0;
status_variables.active_transactions=0;
}
@ -2405,6 +2408,24 @@ SQLite3_result * MySQL_Threads_Handler::SQL3_GlobalStatus() {
result->add_row(pta);
}
}
{ // ConnPool_get_conn_immediate
pta[0]=(char *)"ConnPool_get_conn_immediate";
sprintf(buf,"%llu",get_ConnPool_get_conn_immediate());
pta[1]=buf;
result->add_row(pta);
}
{ // ConnPool_get_conn_success
pta[0]=(char *)"ConnPool_get_conn_success";
sprintf(buf,"%llu",get_ConnPool_get_conn_success());
pta[1]=buf;
result->add_row(pta);
}
{ // ConnPool_get_conn_failure
pta[0]=(char *)"ConnPool_get_conn_failure";
sprintf(buf,"%llu",get_ConnPool_get_conn_failure());
pta[1]=buf;
result->add_row(pta);
}
free(pta);
return result;
}
@ -2809,3 +2830,42 @@ void MySQL_Thread::return_local_connections() {
MyHGM->push_MyConn_to_pool_array(ca);
free(ca);
}
unsigned long long MySQL_Threads_Handler::get_ConnPool_get_conn_immediate() {
unsigned long long q=0;
unsigned int i;
for (i=0;i<num_threads;i++) {
if (mysql_threads) {
MySQL_Thread *thr=(MySQL_Thread *)mysql_threads[i].worker;
if (thr)
q+=__sync_fetch_and_add(&thr->status_variables.ConnPool_get_conn_immediate,0);
}
}
return q;
}
unsigned long long MySQL_Threads_Handler::get_ConnPool_get_conn_success() {
unsigned long long q=0;
unsigned int i;
for (i=0;i<num_threads;i++) {
if (mysql_threads) {
MySQL_Thread *thr=(MySQL_Thread *)mysql_threads[i].worker;
if (thr)
q+=__sync_fetch_and_add(&thr->status_variables.ConnPool_get_conn_success,0);
}
}
return q;
}
unsigned long long MySQL_Threads_Handler::get_ConnPool_get_conn_failure() {
unsigned long long q=0;
unsigned int i;
for (i=0;i<num_threads;i++) {
if (mysql_threads) {
MySQL_Thread *thr=(MySQL_Thread *)mysql_threads[i].worker;
if (thr)
q+=__sync_fetch_and_add(&thr->status_variables.ConnPool_get_conn_failure,0);
}
}
return q;
}

Loading…
Cancel
Save