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

Test main.log_slow_always_query_time is inefficient and overly restrictive

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • N/A
    • 11.5
    • Tests
    • None

    Description

      The test main.log_slow_always_query_time was added in the scope of MDEV-33144 (Implement the Percona variable slow_query_log_always_write_time). It has several flaws which deserve fixing.

      1) The test contains

      --source include/have_debug.inc
      

      It means it will be skipped on the majority of builders in the CIs. However, there is nothing debug-specific in the test, and if I remove the line, it seems to be running just fine on a non-debug build.

      2) The test contains

      --source include/restart_mysqld.inc
      

      Not only does it prolong execution time, but it also makes the test not runnable with the embedded server, which further reduces its scope.
      The comment justifying restart says "Force deterministic session and query ids".
      However, the test doesn't check session/query IDs, it doesn't print the actual slow log into the output. I don't see any immediate problem if I remove the restart and run the test after another one.

      3) The test only runs a few statements, but its execution time is 17+ seconds, which is quite a lot. The reason is that it sets log_slow_always_query_time to 10 and log_slow_query_time to 5, and then runs SELECT sleep(11) and SELECT sleep(6) to exceed these settings. There is no point in that, it could just as well set the variables to 10 times smaller values and sleep much less; such long intervals don't improve the reliability of the test.

      To put it all together, I suggest something like this:

      iff --git a/mysql-test/main/log_slow_always_query_time.result b/mysql-test/main/log_slow_always_query_time.result
      index 381f0cccf57..8994ad6d3ce 100644
      --- a/mysql-test/main/log_slow_always_query_time.result
      +++ b/mysql-test/main/log_slow_always_query_time.result
      @@ -1,4 +1,3 @@
      -# restart
       select @@session.log_slow_always_query_time;
       @@session.log_slow_always_query_time
       31536000.000000
      @@ -8,15 +7,15 @@ select @@global.log_slow_always_query_time, @@session.log_slow_always_query_time
       @@global.log_slow_always_query_time    @@session.log_slow_always_query_time
       20.200000      20.200000
       set GLOBAL log_slow_always_query_time= default;
      -SET log_slow_query_time=5.0;
      +SET log_slow_query_time=0.5;
       SET log_slow_rate_limit=999;
      -SET log_slow_always_query_time=10.0;
      +SET log_slow_always_query_time=1.5;
       SET log_slow_min_examined_row_limit= 100;
       [slow_log_start.inc] log_slow_always_query_time-1
      -SELECT sleep(11) as 'this-should-be-logged';
      +SELECT sleep(2) as 'this-should-be-logged';
       this-should-be-logged
       0
      -SELECT sleep(6) as 'this-should-not-be-logged';
      +SELECT sleep(1) as 'this-should-not-be-logged';
       this-should-not-be-logged
       0
       [log_grep.inc] file: log_slow_always_query_time-1 pattern: this-should expected_matches: 1
      diff --git a/mysql-test/main/log_slow_always_query_time.test b/mysql-test/main/log_slow_always_query_time.test
      index 0f7c58aafac..e4bb8e40ddc 100644
      --- a/mysql-test/main/log_slow_always_query_time.test
      +++ b/mysql-test/main/log_slow_always_query_time.test
      @@ -1,4 +1,3 @@
      ---source include/have_debug.inc
       --source include/not_valgrind.inc
       --disable_ps2_protocol
       
      @@ -6,8 +5,6 @@
       # Test log_slow_always_query_time variable usage
       #
       
      -# Force deterministic session and query ids
      ---source include/restart_mysqld.inc
       --source include/log_slow_prepare.inc
       
       --let $log_slow_prefix=log_slow_always_query_time
      @@ -19,14 +16,14 @@ SET SESSION log_slow_always_query_time=20.2;
       select @@global.log_slow_always_query_time, @@session.log_slow_always_query_time;
       set GLOBAL log_slow_always_query_time= default;
       
      -SET log_slow_query_time=5.0;
      +SET log_slow_query_time=0.5;
       SET log_slow_rate_limit=999;
      -SET log_slow_always_query_time=10.0;
      +SET log_slow_always_query_time=1.5;
       SET log_slow_min_examined_row_limit= 100;
       
       --source include/log_slow_start.inc
      -SELECT sleep(11) as 'this-should-be-logged';
      -SELECT sleep(6) as 'this-should-not-be-logged';
      +SELECT sleep(2) as 'this-should-be-logged';
      +SELECT sleep(1) as 'this-should-not-be-logged';
       
       --let grep_pattern=this-should
       --let $log_expected_matches=1
      

      (times can be changed to something a little longer or more different from each other if there is a need for this, but those which there are now are definitely excessive).

      Attachments

        Issue Links

          Activity

            People

              monty Michael Widenius
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

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