Description:
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 "general_log" into OFF, the table "general_log" is still keeping open until "flush tables" command is entered.
The ideal situation is that when general_log turns into OFF, the table general_log should be closed right now. Otherwise, the big table would occupy lots of cache, which might affect the performance of the cache-related operations.
We check the open tables by the command "show open tables from mysql;"
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';
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 general_log = OFF;
show global variables where variable_name like 'general_log';
show open tables from mysql;
flush tables;
show global variables where variable_name like 'general_log';
show open tables from mysql;
Suggested fix:
when runtime change "general_log", the function fix_general_log_state will be called. Maybe we can close the table general_log during fix_general_log_state.
static bool fix_general_log_state(sys_var *self, THD *thd, enum_var_type type)