From 0e0cb772aaa8cc008f4b073f0b25d8ccc6c6faa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Sun, 24 Jul 2016 08:06:28 +0000 Subject: [PATCH] Debugging in Mon Connection Pool --- lib/MySQL_Monitor.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/lib/MySQL_Monitor.cpp b/lib/MySQL_Monitor.cpp index 10aa9f20c..ce7eba25d 100644 --- a/lib/MySQL_Monitor.cpp +++ b/lib/MySQL_Monitor.cpp @@ -155,7 +155,14 @@ void MySQL_Monitor_Connection_Pool::purge_idle_connections() { unsigned long long now=monotonic_time(); pthread_mutex_lock(&mutex); std::map*>::iterator it; - fprintf(stderr,"conn pool size: %d\n",my_connections.size()); + fprintf(stderr,"conn pool size: %d\n",my_connections.size()); + unsigned int totconn; + totconn=0; + for(it = my_connections.begin(); it != my_connections.end(); it++) { + std::list *lst=it->second; + totconn+=lst->size(); + } + fprintf(stderr,"tot conn in pool: %d\n",totconn); for(it = my_connections.begin(); it != my_connections.end(); it++) { std::list *lst=it->second; if (!lst->empty()) { @@ -195,6 +202,12 @@ void MySQL_Monitor_Connection_Pool::purge_idle_connections() { my_connections.erase(it); } } + totconn=0; + for(it = my_connections.begin(); it != my_connections.end(); it++) { + std::list *lst=it->second; + totconn+=lst->size(); + } + fprintf(stderr,"tot conn in pool: %d\n",totconn); pthread_mutex_unlock(&mutex); } @@ -1405,18 +1418,18 @@ void * MySQL_Monitor::run() { //proxy_error("%s\n","MySQL_Monitor refreshing variables"); //My_Conn_Pool->purge_missing_servers(NULL); } - if ( rand()%4 == 0) { // purge once in a while + if ( rand()%2 == 0) { // purge once in a while My_Conn_Pool->purge_idle_connections(); } usleep(500000); int qsize=queue.size(); - if (qsize>200) { + if (qsize>500) { proxy_error("Monitor queue too big, try to reduce frequency of checks: %d\n", qsize); - qsize=qsize/100; + qsize=qsize/250; proxy_error("Monitor is starting %d helper threads\n", qsize); ConsumerThread **threads_aux= (ConsumerThread **)malloc(sizeof(ConsumerThread *)*qsize); for (int i=0; istart(); } for (int i=0; i