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

log_query_not_using_indexes=OFF does not work when log_slow_filter is empty string

    XMLWordPrintable

Details

    Description

      When set it on my.cnf
      [mysqld]
      slow_query_log=ON
      log_queries_not_using_indexes=OFF
      log_slow_filter=

      Run query

      create database slow;
      create table slow.t(int id, int k);
      insert into slow.t values (1, 1);
      insert into slow.t values (2, 2);
      select * from slow.t;
      

      Then the query not using indexes will be logged into slow log. The is a wrong behavior due to document and is different from previous version like 10.2.

      Analysis

      On file sql_parse.cc

        if ((thd->server_status &
             (SERVER_QUERY_NO_INDEX_USED | SERVER_QUERY_NO_GOOD_INDEX_USED)) &&
            !(thd->query_plan_flags & QPLAN_STATUS) &&
            !slow_filter_masked(thd, QPLAN_NOT_USING_INDEX))
        {
          thd->query_plan_flags|= QPLAN_NOT_USING_INDEX;
          /* We are always logging no index queries if enabled in filter */
          thd->server_status|= SERVER_QUERY_WAS_SLOW;
        }
      

      The slow_filter_masked is

      static bool slow_filter_masked(THD *thd, ulonglong mask)
      {
        return thd->variables.log_slow_filter && !(thd->variables.log_slow_filter & mask);
      }
      

      Which means the function return false when `log_slow_filter` is 0, which is set when in config it is a empty string. And then log_queries_not_using_indexes=OFF does not work and always log the not using indexes queries.

      Attachments

        Issue Links

          Activity

            People

              danblack Daniel Black
              shuodl Shuode Li
              Votes:
              0 Vote for this issue
              Watchers:
              4 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.