@@ -2301,7 +2301,7 @@ class thread_info :public ilink {
2301
2301
{ TRASH (ptr, size); }
2302
2302
2303
2303
ulong thread_id;
2304
- time_t start_time;
2304
+ ulonglong start_time;
2305
2305
uint command;
2306
2306
const char *user,*host,*db,*proc_info,*state_info;
2307
2307
CSET_STRING query_string;
@@ -2432,15 +2432,18 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose)
2432
2432
}
2433
2433
else
2434
2434
thd_info->progress = 0.0 ;
2435
- thd_info->start_time = tmp->start_time ;
2435
+ thd_info->start_time = tmp->start_utime ;
2436
+ ulonglong utime_after_query_snapshot= tmp->utime_after_query ;
2437
+ if (thd_info->start_time < utime_after_query_snapshot)
2438
+ thd_info->start_time = utime_after_query_snapshot; // COM_SLEEP
2436
2439
mysql_mutex_unlock (&tmp->LOCK_thd_data );
2437
2440
thread_infos.append (thd_info);
2438
2441
}
2439
2442
}
2440
2443
mysql_mutex_unlock (&LOCK_thread_count);
2441
2444
2442
2445
thread_info *thd_info;
2443
- time_t now= my_time ( 0 );
2446
+ ulonglong now= microsecond_interval_timer ( );
2444
2447
char buff[20 ]; // For progress
2445
2448
String store_buffer (buff, sizeof (buff), system_charset_info);
2446
2449
@@ -2455,8 +2458,8 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose)
2455
2458
protocol->store (thd_info->proc_info , system_charset_info);
2456
2459
else
2457
2460
protocol->store (command_name[thd_info->command ].str , system_charset_info);
2458
- if (thd_info->start_time )
2459
- protocol->store_long ((longlong) ( now - thd_info->start_time ) );
2461
+ if (thd_info->start_time && now > thd_info-> start_time )
2462
+ protocol->store_long ( now - thd_info->start_time );
2460
2463
else
2461
2464
protocol->store_null ();
2462
2465
protocol->store (thd_info->state_info , system_charset_info);
@@ -2730,7 +2733,7 @@ int fill_schema_processlist(THD* thd, TABLE_LIST* tables, COND* cond)
2730
2733
TABLE *table= tables->table ;
2731
2734
CHARSET_INFO *cs= system_charset_info;
2732
2735
char *user;
2733
- my_hrtime_t unow= my_hrtime ();
2736
+ ulonglong unow= microsecond_interval_timer ();
2734
2737
DBUG_ENTER (" fill_schema_processlist" );
2735
2738
2736
2739
DEBUG_SYNC (thd," fill_schema_processlist_after_unow" );
@@ -2793,9 +2796,12 @@ int fill_schema_processlist(THD* thd, TABLE_LIST* tables, COND* cond)
2793
2796
table->field [4 ]->store (command_name[tmp->get_command ()].str ,
2794
2797
command_name[tmp->get_command ()].length , cs);
2795
2798
/* MYSQL_TIME */
2796
- ulonglong start_utime= tmp->start_time * HRTIME_RESOLUTION + tmp->start_time_sec_part ;
2797
- ulonglong utime= start_utime && start_utime < unow.val
2798
- ? unow.val - start_utime : 0 ;
2799
+ ulonglong utime= tmp->start_utime ;
2800
+ ulonglong utime_after_query_snapshot= tmp->utime_after_query ;
2801
+ if (utime < utime_after_query_snapshot)
2802
+ utime= utime_after_query_snapshot; // COM_SLEEP
2803
+ utime= utime && utime < unow ? unow - utime : 0 ;
2804
+
2799
2805
table->field [5 ]->store (utime / HRTIME_RESOLUTION, TRUE );
2800
2806
/* STATE */
2801
2807
if ((val= thread_state_info (tmp)))
0 commit comments