From c987da5b03262a03b647775970c741eb5ae1a16d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Sat, 17 Sep 2016 08:05:03 +0000 Subject: [PATCH] Various changes - "Prepare" wasn't listed in SHOW PROCESSLIST - during ~MySQL_Connection(), all --- lib/MySQL_HostGroups_Manager.cpp | 9 +++++++-- lib/MySQL_PreparedStatement.cpp | 2 +- lib/MySQL_Thread.cpp | 3 +++ lib/mysql_connection.cpp | 1 + 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/MySQL_HostGroups_Manager.cpp b/lib/MySQL_HostGroups_Manager.cpp index 95929836a..1b1768484 100644 --- a/lib/MySQL_HostGroups_Manager.cpp +++ b/lib/MySQL_HostGroups_Manager.cpp @@ -635,8 +635,13 @@ void MySQL_HostGroups_Manager::push_MyConn_to_pool(MySQL_Connection *c, bool _lo } if (mysrvc->status==MYSQL_SERVER_STATUS_ONLINE) { if (c->async_state_machine==ASYNC_IDLE) { - c->optimize(); - mysrvc->ConnectionsFree->add(c); + if (c->local_stmts->get_num_entries() > 50) { + proxy_debug(PROXY_DEBUG_MYSQL_CONNPOOL, 7, "Destroying MySQL_Connection %p, server %s:%d with status %d because has too many prepared statements\n", c, mysrvc->address, mysrvc->port, mysrvc->status); + delete c; + } else { + c->optimize(); + mysrvc->ConnectionsFree->add(c); + } } else { proxy_debug(PROXY_DEBUG_MYSQL_CONNPOOL, 7, "Destroying MySQL_Connection %p, server %s:%d with status %d\n", c, mysrvc->address, mysrvc->port, mysrvc->status); delete c; diff --git a/lib/MySQL_PreparedStatement.cpp b/lib/MySQL_PreparedStatement.cpp index 522771fa2..cc8f21591 100644 --- a/lib/MySQL_PreparedStatement.cpp +++ b/lib/MySQL_PreparedStatement.cpp @@ -132,7 +132,7 @@ void MySQL_STMT_Manager::active_prepared_statements(uint32_t *unique, uint32_t * uint32_t u=0; uint32_t t=0; spin_wrlock(&rwlock); - fprintf(stderr,"%u , %u\n", find_prepared_statement_by_hash_calls, add_prepared_statement_calls); + fprintf(stderr,"%u , %u , %u\n", find_prepared_statement_by_hash_calls, add_prepared_statement_calls, m.size()); for (std::map::iterator it=m.begin(); it!=m.end(); ++it) { MySQL_STMT_Global_info *a=it->second; if (a->ref_count_client) { diff --git a/lib/MySQL_Thread.cpp b/lib/MySQL_Thread.cpp index 124b2ab79..4a270b7b5 100644 --- a/lib/MySQL_Thread.cpp +++ b/lib/MySQL_Thread.cpp @@ -2598,6 +2598,9 @@ SQLite3_result * MySQL_Threads_Handler::SQL3_Processlist() { case PROCESSING_STMT_EXECUTE: pta[11]=strdup("Execute"); break; + case PROCESSING_STMT_PREPARE: + pta[11]=strdup("Prepare"); + break; default: sprintf(buf,"%d", sess->status); pta[11]=strdup(buf); diff --git a/lib/mysql_connection.cpp b/lib/mysql_connection.cpp index 545dda109..5b7dfd176 100644 --- a/lib/mysql_connection.cpp +++ b/lib/mysql_connection.cpp @@ -214,6 +214,7 @@ MySQL_Connection::~MySQL_Connection() { delete local_stmts; } if (query.stmt) { + query.stmt->mysql=NULL; mysql_stmt_close(query.stmt); query.stmt=NULL; }