[MDEV-21187] log_query_not_using_indexes=OFF does not work when log_slow_filter is empty string Created: 2019-12-02  Updated: 2022-12-13  Resolved: 2022-12-13

Status: Closed
Project: MariaDB Server
Component/s: Server
Affects Version/s: 10.3.20, 10.3, 10.4
Fix Version/s: 10.11.2, 10.3.38, 10.4.28, 10.5.19, 10.6.12, 10.7.8, 10.8.7, 10.9.5, 10.10.3

Type: Bug Priority: Major
Reporter: Shuode Li Assignee: Daniel Black
Resolution: Fixed Votes: 0
Labels: None
Environment:

All platform



 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.



 Comments   
Comment by Alice Sherepa [ 2019-12-02 ]

Thanks! I reproduced as described on current 10.3, 10.4

Comment by Michael Widenius [ 2022-12-13 ]

At some point we should change so that log_slow_filter="" would be same as log_slow_filter="all_type_of_queries"
This would simplify all other testing code as we don't have do a special case for log_slow_filter is empty.
However, this for the future, not now...

Comment by Michael Widenius [ 2022-12-13 ]

Requested a simple change in submitted patch.
Ok to push after this is fixed.

Generated at Thu Feb 08 09:05:14 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.