summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sql/mysqld.cc7
-rw-r--r--sql/sql_class.cc2
-rw-r--r--sql/sql_class.h3
-rw-r--r--sql/sql_connect.cc20
4 files changed, 23 insertions, 9 deletions
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index eb94e1a8fab..239fff01071 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -4780,8 +4780,9 @@ void handle_connection_in_main_thread(THD *thd)
safe_mutex_assert_owner(&LOCK_thread_count);
thread_cache_size=0; // Safety
threads.append(thd);
- (void) pthread_mutex_unlock(&LOCK_thread_count);
- handle_one_connection((void*) thd);
+ pthread_mutex_unlock(&LOCK_thread_count);
+ thd->start_utime= my_micro_time();
+ handle_one_connection(thd);
}
@@ -4806,7 +4807,7 @@ void create_thread_to_handle_connection(THD *thd)
thread_created++;
threads.append(thd);
DBUG_PRINT("info",(("creating thread %lu"), thd->thread_id));
- thd->connect_utime= thd->start_utime= my_micro_time();
+ thd->prior_thr_create_utime= thd->start_utime= my_micro_time();
if ((error=pthread_create(&thd->real_id,&connection_attrib,
handle_one_connection,
(void*) thd)))
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index f881f0a792b..f1ad410b877 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -590,7 +590,7 @@ THD::THD()
// Must be reset to handle error with THD's created for init of mysqld
lex->current_select= 0;
start_time=(time_t) 0;
- start_utime= 0L;
+ start_utime= prior_thr_create_utime= 0L;
utime_after_lock= 0L;
current_linfo = 0;
slave_thread = 0;
diff --git a/sql/sql_class.h b/sql/sql_class.h
index ae7f2a51428..36e696f2da6 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -1370,7 +1370,8 @@ public:
/* remote (peer) port */
uint16 peer_port;
time_t start_time, user_time;
- ulonglong connect_utime, thr_create_utime; // track down slow pthread_create
+ // track down slow pthread_create
+ ulonglong prior_thr_create_utime, thr_create_utime;
ulonglong start_utime, utime_after_lock;
thr_lock_type update_lock_default;
diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc
index e4d7cf6feb5..98574a07a4e 100644
--- a/sql/sql_connect.cc
+++ b/sql/sql_connect.cc
@@ -1074,8 +1074,8 @@ static void prepare_new_connection_state(THD* thd)
pthread_handler_t handle_one_connection(void *arg)
{
THD *thd= (THD*) arg;
- ulong launch_time= (ulong) ((thd->thr_create_utime= my_micro_time()) -
- thd->connect_utime);
+
+ thd->thr_create_utime= my_micro_time();
if (thread_scheduler.init_new_connection_thread())
{
@@ -1084,8 +1084,20 @@ pthread_handler_t handle_one_connection(void *arg)
thread_scheduler.end_thread(thd,0);
return 0;
}
- if (launch_time >= slow_launch_time*1000000L)
- statistic_increment(slow_launch_threads,&LOCK_status);
+
+ /*
+ If a thread was created to handle this connection:
+ increment slow_launch_threads counter if it took more than
+ slow_launch_time seconds to create the thread.
+ */
+ if (thd->prior_thr_create_utime)
+ {
+ ulong launch_time= (ulong) (thd->thr_create_utime -
+ thd->prior_thr_create_utime);
+ if (launch_time >= slow_launch_time*1000000L)
+ statistic_increment(slow_launch_threads, &LOCK_status);
+ thd->prior_thr_create_utime= 0;
+ }
/*
handle_one_connection() is normally the only way a thread would