Commit db50f37a authored by unknown's avatar unknown

Bug#16918: Aborted_clients > Connections.

The problem was that aborted_threads variable was updated
twice when a client connection had been aborted.

The fix is to refactor a code to have aborted_threads updated
only in one place.


sql/mysql_priv.h:
  Make do_command() a private function.
sql/sql_parse.cc:
  1. Make do_command() a private function;
  2. Update aborted_threads in the only one place.
parent 5c836d24
...@@ -726,7 +726,6 @@ pthread_handler_t handle_bootstrap(void *arg); ...@@ -726,7 +726,6 @@ pthread_handler_t handle_bootstrap(void *arg);
void end_thread(THD *thd,bool put_in_cache); void end_thread(THD *thd,bool put_in_cache);
void flush_thread_cache(); void flush_thread_cache();
bool mysql_execute_command(THD *thd); bool mysql_execute_command(THD *thd);
bool do_command(THD *thd);
bool dispatch_command(enum enum_server_command command, THD *thd, bool dispatch_command(enum enum_server_command command, THD *thd,
char* packet, uint packet_length); char* packet, uint packet_length);
void log_slow_statement(THD *thd); void log_slow_statement(THD *thd);
......
...@@ -93,6 +93,8 @@ const char *xa_state_names[]={ ...@@ -93,6 +93,8 @@ const char *xa_state_names[]={
"NON-EXISTING", "ACTIVE", "IDLE", "PREPARED" "NON-EXISTING", "ACTIVE", "IDLE", "PREPARED"
}; };
static bool do_command(THD *thd);
#ifdef __WIN__ #ifdef __WIN__
static void test_signal(int sig_ptr) static void test_signal(int sig_ptr)
{ {
...@@ -1199,21 +1201,26 @@ pthread_handler_t handle_one_connection(void *arg) ...@@ -1199,21 +1201,26 @@ pthread_handler_t handle_one_connection(void *arg)
} }
if (thd->user_connect) if (thd->user_connect)
decrease_user_connections(thd->user_connect); decrease_user_connections(thd->user_connect);
if (thd->killed ||
net->vio && net->error && net->report_error)
{
statistic_increment(aborted_threads, &LOCK_status);
}
if (net->error && net->vio != 0 && net->report_error) if (net->error && net->vio != 0 && net->report_error)
{ {
if (!thd->killed && thd->variables.log_warnings > 1) if (!thd->killed && thd->variables.log_warnings > 1)
{
sql_print_warning(ER(ER_NEW_ABORTING_CONNECTION), sql_print_warning(ER(ER_NEW_ABORTING_CONNECTION),
thd->thread_id,(thd->db ? thd->db : "unconnected"), thd->thread_id,(thd->db ? thd->db : "unconnected"),
sctx->user ? sctx->user : "unauthenticated", sctx->user ? sctx->user : "unauthenticated",
sctx->host_or_ip, sctx->host_or_ip,
(net->last_errno ? ER(net->last_errno) : (net->last_errno ? ER(net->last_errno) :
ER(ER_UNKNOWN_ERROR))); ER(ER_UNKNOWN_ERROR)));
net_send_error(thd, net->last_errno, NullS);
statistic_increment(aborted_threads,&LOCK_status);
} }
else if (thd->killed)
{ net_send_error(thd, net->last_errno, NullS);
statistic_increment(aborted_threads,&LOCK_status);
} }
end_thread: end_thread:
...@@ -1550,12 +1557,12 @@ bool do_command(THD *thd) ...@@ -1550,12 +1557,12 @@ bool do_command(THD *thd)
DBUG_PRINT("info",("Got error %d reading command from socket %s", DBUG_PRINT("info",("Got error %d reading command from socket %s",
net->error, net->error,
vio_description(net->vio))); vio_description(net->vio)));
/* Check if we can continue without closing the connection */ /* Check if we can continue without closing the connection */
if (net->error != 3) if (net->error != 3)
{
statistic_increment(aborted_threads,&LOCK_status);
DBUG_RETURN(TRUE); // We have to close it. DBUG_RETURN(TRUE); // We have to close it.
}
net_send_error(thd, net->last_errno, NullS); net_send_error(thd, net->last_errno, NullS);
net->error= 0; net->error= 0;
DBUG_RETURN(FALSE); DBUG_RETURN(FALSE);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment