Commit 85a8de31 authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-4578 information_schema.processlist reports incorrect value for Time (2147483647)

SHOW PROCESSLIST might see a thread that started executing a query *after*
processlist has started. Don't show a negative or huge wrapped-around query execution time.
parent 1fb33e4a
SET DEBUG_SYNC = 'dispatch_command_before_set_time WAIT_FOR do_set_time';
SELECT 1;
SET DEBUG_SYNC = 'fill_schema_processlist_after_unow SIGNAL do_set_time WAIT_FOR fill_schema_proceed';
SELECT INFO,TIME,TIME_MS FROM INFORMATION_SCHEMA.PROCESSLIST WHERE INFO IS NULL;
1
1
SET DEBUG_SYNC = 'now SIGNAL fill_schema_proceed';
INFO TIME TIME_MS
NULL 0 0.000
#
# MDEV-4578 information_schema.processlist reports incorrect value for Time (2147483647)
#
source include/have_debug_sync.inc;
SET DEBUG_SYNC = 'dispatch_command_before_set_time WAIT_FOR do_set_time';
send SELECT 1;
connect (con1,localhost,root,,);
SET DEBUG_SYNC = 'fill_schema_processlist_after_unow SIGNAL do_set_time WAIT_FOR fill_schema_proceed';
send SELECT INFO,TIME,TIME_MS FROM INFORMATION_SCHEMA.PROCESSLIST WHERE INFO IS NULL;
connection default;
reap;
SET DEBUG_SYNC = 'now SIGNAL fill_schema_proceed';
connection con1;
reap;
disconnect con1;
...@@ -914,6 +914,9 @@ bool dispatch_command(enum enum_server_command command, THD *thd, ...@@ -914,6 +914,9 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
thd->enable_slow_log= TRUE; thd->enable_slow_log= TRUE;
thd->query_plan_flags= QPLAN_INIT; thd->query_plan_flags= QPLAN_INIT;
thd->lex->sql_command= SQLCOM_END; /* to avoid confusing VIEW detectors */ thd->lex->sql_command= SQLCOM_END; /* to avoid confusing VIEW detectors */
DEBUG_SYNC(thd,"dispatch_command_before_set_time");
thd->set_time(); thd->set_time();
thd->set_query_id(get_query_id()); thd->set_query_id(get_query_id());
if (!(server_command_flags[command] & CF_SKIP_QUERY_ID)) if (!(server_command_flags[command] & CF_SKIP_QUERY_ID))
......
...@@ -2297,6 +2297,8 @@ int fill_schema_processlist(THD* thd, TABLE_LIST* tables, COND* cond) ...@@ -2297,6 +2297,8 @@ int fill_schema_processlist(THD* thd, TABLE_LIST* tables, COND* cond)
my_hrtime_t unow= my_hrtime(); my_hrtime_t unow= my_hrtime();
DBUG_ENTER("fill_schema_processlist"); DBUG_ENTER("fill_schema_processlist");
DEBUG_SYNC(thd,"fill_schema_processlist_after_unow");
user= thd->security_ctx->master_access & PROCESS_ACL ? user= thd->security_ctx->master_access & PROCESS_ACL ?
NullS : thd->security_ctx->priv_user; NullS : thd->security_ctx->priv_user;
...@@ -2355,9 +2357,8 @@ int fill_schema_processlist(THD* thd, TABLE_LIST* tables, COND* cond) ...@@ -2355,9 +2357,8 @@ int fill_schema_processlist(THD* thd, TABLE_LIST* tables, COND* cond)
table->field[4]->store(command_name[tmp->command].str, table->field[4]->store(command_name[tmp->command].str,
command_name[tmp->command].length, cs); command_name[tmp->command].length, cs);
/* MYSQL_TIME */ /* MYSQL_TIME */
const ulonglong utime= (tmp->start_time ? ulonglong start_utime= tmp->start_time * HRTIME_RESOLUTION + tmp->start_time_sec_part;
(unow.val - tmp->start_time * HRTIME_RESOLUTION - ulonglong utime= start_utime < unow.val ? unow.val - start_utime : 0;
tmp->start_time_sec_part) : 0);
table->field[5]->store(utime / HRTIME_RESOLUTION, TRUE); table->field[5]->store(utime / HRTIME_RESOLUTION, TRUE);
/* STATE */ /* STATE */
if ((val= thread_state_info(tmp))) if ((val= thread_state_info(tmp)))
......
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