Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-11628

mysql.slow_log reports incorrect start time

Details

    Description

      MariaDB [test]> truncate mysql.slow_log;
      Query OK, 0 rows affected (0.00 sec)
       
      MariaDB [test]> select current_time(); select sleep(10); select current_time();
      +----------------+
      | current_time() |
      +----------------+
      | 17:24:37       |
      +----------------+
      1 row in set (0.00 sec)
       
      +-----------+
      | sleep(10) |
      +-----------+
      |         0 |
      +-----------+
      1 row in set (10.00 sec)
       
      +----------------+
      | current_time() |
      +----------------+
      | 17:24:47       |
      +----------------+
      1 row in set (0.00 sec)
       
      MariaDB [test]> select start_time, sql_text from mysql.slow_log;
      +----------------------------+-------------------------+
      | start_time                 | sql_text                |
      +----------------------------+-------------------------+
      | 2016-12-21 17:24:15.320518 | truncate mysql.slow_log |
      | 2016-12-21 17:24:37.593565 | select current_time()   |
      | 2016-12-21 17:24:47.595008 | select sleep(10)        | <-- Start time is ~10sec after previous command
      | 2016-12-21 17:24:47.596239 | select current_time()   |
      +----------------------------+-------------------------+
      4 rows in set (0.00 sec)
      
      

      Attachments

        Issue Links

          Activity

            nirbhay_c Nirbhay Choubey (Inactive) created issue -
            nirbhay_c Nirbhay Choubey (Inactive) made changes -
            Field Original Value New Value
            Fix Version/s 10.2.2 [ 22013 ]
            nirbhay_c Nirbhay Choubey (Inactive) made changes -
            Affects Version/s 5.5.53 [ 22106 ]
            Affects Version/s 10.1.20 [ 22112 ]
            Affects Version/s 10.0.28 [ 22107 ]

            diff --git a/sql/log.cc b/sql/log.cc
            index 569942a..b46d6d6 100644
            --- a/sql/log.cc
            +++ b/sql/log.cc
            @@ -1317,8 +1317,8 @@ bool LOGGER::slow_log_print(THD *thd, const char *query, uint query_length,
                 DBUG_ASSERT(thd->start_time);
                 query_utime= (current_utime - thd->start_utime);
                 lock_utime=  (thd->utime_after_lock - thd->start_utime);
            -    my_hrtime_t current_time= { hrtime_from_time(thd->start_time) +
            -                                thd->start_time_sec_part + query_utime };
            +    my_hrtime_t start_time= { hrtime_from_time(thd->start_time) +
            +                              thd->start_time_sec_part };
             
                 if (!query)
                 {
            @@ -1328,7 +1328,7 @@ bool LOGGER::slow_log_print(THD *thd, const char *query, uint query_length,
                 }
             
                 for (current_handler= slow_log_handler_list; *current_handler ;)
            -      error= (*current_handler++)->log_slow(thd, current_time,
            +      error= (*current_handler++)->log_slow(thd, start_time,
                                                         user_host_buff, user_host_len,
                                                         query_utime, lock_utime, is_command,
                                                         query, query_length) || error;
            

            nirbhay_c Nirbhay Choubey (Inactive) added a comment - diff --git a/sql/log.cc b/sql/log.cc index 569942a..b46d6d6 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1317,8 +1317,8 @@ bool LOGGER::slow_log_print(THD *thd, const char *query, uint query_length, DBUG_ASSERT(thd->start_time); query_utime= (current_utime - thd->start_utime); lock_utime= (thd->utime_after_lock - thd->start_utime); - my_hrtime_t current_time= { hrtime_from_time(thd->start_time) + - thd->start_time_sec_part + query_utime }; + my_hrtime_t start_time= { hrtime_from_time(thd->start_time) + + thd->start_time_sec_part }; if (!query) { @@ -1328,7 +1328,7 @@ bool LOGGER::slow_log_print(THD *thd, const char *query, uint query_length, } for (current_handler= slow_log_handler_list; *current_handler ;) - error= (*current_handler++)->log_slow(thd, current_time, + error= (*current_handler++)->log_slow(thd, start_time, user_host_buff, user_host_len, query_utime, lock_utime, is_command, query, query_length) || error;
            elenst Elena Stepanova made changes -
            Fix Version/s 10.1 [ 16100 ]
            Fix Version/s 10.2 [ 14601 ]
            Affects Version/s 5.5 [ 15800 ]
            Affects Version/s 10.0 [ 16000 ]
            Affects Version/s 10.1 [ 16100 ]
            Affects Version/s 10.2 [ 14601 ]
            Labels logging logging upstream
            elenst Elena Stepanova made changes -
            elenst Elena Stepanova made changes -
            Status Open [ 1 ] Confirmed [ 10101 ]
            danblack Daniel Black made changes -
            Labels logging upstream logging patch upstream
            julien.fritsch Julien Fritsch made changes -
            Fix Version/s 10.1 [ 16100 ]
            serg Sergei Golubchik made changes -
            Workflow MariaDB v3 [ 78859 ] MariaDB v4 [ 143916 ]
            elenst Elena Stepanova made changes -
            Fix Version/s 10.5 [ 23123 ]
            Fix Version/s 10.6 [ 24028 ]
            Fix Version/s 10.11 [ 27614 ]
            Fix Version/s 11.0 [ 28320 ]
            Fix Version/s 11.1 [ 28549 ]
            Fix Version/s 11.2 [ 28603 ]
            Fix Version/s 11.3 [ 28565 ]
            Fix Version/s 10.2 [ 14601 ]
            Affects Version/s 10.4 [ 22408 ]
            Affects Version/s 10.5 [ 23123 ]
            Affects Version/s 10.6 [ 24028 ]
            Affects Version/s 10.11 [ 27614 ]
            Affects Version/s 11.0 [ 28320 ]
            Affects Version/s 11.1 [ 28549 ]
            Affects Version/s 11.2 [ 28603 ]
            Affects Version/s 11.3 [ 28565 ]
            Affects Version/s 11.4 [ 29301 ]
            elenst Elena Stepanova made changes -
            serg Sergei Golubchik made changes -
            Assignee Sergei Golubchik [ serg ]
            serg Sergei Golubchik made changes -
            Fix Version/s 10.5.24 [ 29517 ]
            Fix Version/s 10.6.17 [ 29518 ]
            Fix Version/s 10.11.7 [ 29519 ]
            Fix Version/s 11.0.5 [ 29520 ]
            Fix Version/s 11.1.4 [ 29024 ]
            Fix Version/s 11.2.3 [ 29521 ]
            Fix Version/s 10.5 [ 23123 ]
            Fix Version/s 10.6 [ 24028 ]
            Fix Version/s 10.11 [ 27614 ]
            Fix Version/s 11.0 [ 28320 ]
            Fix Version/s 11.1 [ 28549 ]
            Fix Version/s 11.3 [ 28565 ]
            Fix Version/s 11.2 [ 28603 ]
            serg Sergei Golubchik made changes -
            issue.field.resolutiondate 2024-01-23 23:24:35.0 2024-01-23 23:24:35.227
            serg Sergei Golubchik made changes -
            Resolution Fixed [ 1 ]
            Status Confirmed [ 10101 ] Closed [ 6 ]
            elenst Elena Stepanova made changes -

            People

              serg Sergei Golubchik
              nirbhay_c Nirbhay Choubey (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.