Bug #105964 The table "general_log/slow_log" not close when config log_output set into NONE
Submitted: 23 Dec 2021 1:43 Modified: 23 Dec 2021 5:06
Reporter: teng wang (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Options Severity:S3 (Non-critical)
Version:5.7.35, 8.0.27 OS:Linux
Assigned to: CPU Architecture:Any

[23 Dec 2021 1:43] teng wang
Description:
This is similar to Bug #105933. When we set the config option "general_log" as ON, and "log_output" as TABLE in the config file, MySQL records the related general logs into the table named "general_log". However, if we runtime change the option "log_output" into NONE, the table "general_log" is still keeping open until "flush tables" command is entered. Slow_log is similar.

The ideal situation is that when log_output turns into NONE or FILE, the table general_log/slow_log should be closed right now. Otherwise, the big tables would occupy lots of cache in some situations, which might affect the performance of the cache-related operations.

How to repeat:
set global general_log = 'ON';
set global log_output = 'TABLE';
show global variables where variable_name like 'general_log';
show global variables where variable_name like 'log_output';

flush tables;
create table t1
(
  a int primary key,
  b char(10)
);
insert into t1 values (1,'one');
insert into t1 values (2,'two');
show open tables from mysql;

set global log_output = 'NONE';
show global variables where variable_name like 'log_output';
show open tables from mysql;

flush tables;
insert into t1 values (3,'three');
show global variables where variable_name like 'log_output';
show open tables from mysql;

Suggested fix:
when runtime change "log_output", the function fix_log_output will be called. Maybe we can check and close the table general_log/slow_log during fix_log_output() if "log_output" was updated to NONE or FILE from TABLE.

/* /sql/sys_vars.cc */
static bool fix_log_output(sys_var *self, THD *thd, enum_var_type type)
[23 Dec 2021 5:05] MySQL Verification Team
Hello!

Thank you for the report and feedback.

regards,
Umesh