File tree 4 files changed +23
-9
lines changed
4 files changed +23
-9
lines changed Original file line number Diff line number Diff line change @@ -4780,8 +4780,9 @@ void handle_connection_in_main_thread(THD *thd)
4780
4780
safe_mutex_assert_owner(&LOCK_thread_count);
4781
4781
thread_cache_size=0; // Safety
4782
4782
threads.append(thd);
4783
- (void) pthread_mutex_unlock(&LOCK_thread_count);
4784
- handle_one_connection((void*) thd);
4783
+ pthread_mutex_unlock(&LOCK_thread_count);
4784
+ thd->start_utime= my_micro_time();
4785
+ handle_one_connection(thd);
4785
4786
}
4786
4787
4787
4788
@@ -4806,7 +4807,7 @@ void create_thread_to_handle_connection(THD *thd)
4806
4807
thread_created++;
4807
4808
threads.append(thd);
4808
4809
DBUG_PRINT("info",(("creating thread %lu"), thd->thread_id));
4809
- thd->connect_utime = thd->start_utime= my_micro_time();
4810
+ thd->prior_thr_create_utime = thd->start_utime= my_micro_time();
4810
4811
if ((error=pthread_create(&thd->real_id,&connection_attrib,
4811
4812
handle_one_connection,
4812
4813
(void*) thd)))
Original file line number Diff line number Diff line change @@ -590,7 +590,7 @@ THD::THD()
590
590
// Must be reset to handle error with THD's created for init of mysqld
591
591
lex->current_select = 0 ;
592
592
start_time=(time_t ) 0 ;
593
- start_utime= 0L ;
593
+ start_utime= prior_thr_create_utime= 0L ;
594
594
utime_after_lock= 0L ;
595
595
current_linfo = 0 ;
596
596
slave_thread = 0 ;
Original file line number Diff line number Diff line change @@ -1370,7 +1370,8 @@ class THD :public Statement,
1370
1370
/* remote (peer) port */
1371
1371
uint16 peer_port;
1372
1372
time_t start_time, user_time;
1373
- ulonglong connect_utime, thr_create_utime; // track down slow pthread_create
1373
+ // track down slow pthread_create
1374
+ ulonglong prior_thr_create_utime, thr_create_utime;
1374
1375
ulonglong start_utime, utime_after_lock;
1375
1376
1376
1377
thr_lock_type update_lock_default;
Original file line number Diff line number Diff line change @@ -1074,8 +1074,8 @@ static void prepare_new_connection_state(THD* thd)
1074
1074
pthread_handler_t handle_one_connection (void *arg)
1075
1075
{
1076
1076
THD *thd= (THD*) arg;
1077
- ulong launch_time= (ulong) ((thd-> thr_create_utime = my_micro_time ()) -
1078
- thd->connect_utime );
1077
+
1078
+ thd->thr_create_utime = my_micro_time ( );
1079
1079
1080
1080
if (thread_scheduler.init_new_connection_thread ())
1081
1081
{
@@ -1084,8 +1084,20 @@ pthread_handler_t handle_one_connection(void *arg)
1084
1084
thread_scheduler.end_thread (thd,0 );
1085
1085
return 0 ;
1086
1086
}
1087
- if (launch_time >= slow_launch_time*1000000L )
1088
- statistic_increment (slow_launch_threads,&LOCK_status);
1087
+
1088
+ /*
1089
+ If a thread was created to handle this connection:
1090
+ increment slow_launch_threads counter if it took more than
1091
+ slow_launch_time seconds to create the thread.
1092
+ */
1093
+ if (thd->prior_thr_create_utime )
1094
+ {
1095
+ ulong launch_time= (ulong) (thd->thr_create_utime -
1096
+ thd->prior_thr_create_utime );
1097
+ if (launch_time >= slow_launch_time*1000000L )
1098
+ statistic_increment (slow_launch_threads, &LOCK_status);
1099
+ thd->prior_thr_create_utime = 0 ;
1100
+ }
1089
1101
1090
1102
/*
1091
1103
handle_one_connection() is normally the only way a thread would
You can’t perform that action at this time.
0 commit comments