From c01550035daeaf4bbe83290cae24ce64521c5990 Mon Sep 17 00:00:00 2001 From: yuxianjiang Date: Sun, 25 Jul 2021 00:11:20 +0800 Subject: [PATCH] [bugfix] issue#422 show processlist return invalid value -1 in TIME field MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit problem ==== SQL command “show processlist;” return -1 in TIME field occasionally. But TIME field should not be negative. The reason is that start time and end time are measured by different method and the method has different precision. This cause the end time less than the start time. solution ==== The TIME value '-1' mean that the interval between start time and end time is short. In most cases like this, the value is 0. So here we just assign the value to 0. --- sql/sql_show.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 11d743c..2ee3deb 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -2966,8 +2966,10 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose, bool detail) protocol->store(thd_info->proc_info, system_charset_info); else protocol->store(command_name[thd_info->command].str, system_charset_info); + longlong time = (longlong) (now - thd_info->start_time); + if (time < 0) time = 0; if (thd_info->start_time) - protocol->store_long ((longlong) (now - thd_info->start_time)); + protocol->store_long (time); else protocol->store_null(); protocol->store(thd_info->state_info, system_charset_info); -- 1.8.3.1