[MDEV-29077] The table "general_log" did not close when the config option general_log was set into OFF dynamically Created: 2022-07-10  Updated: 2023-09-19

Status: Open
Project: MariaDB Server
Component/s: Admin statements
Affects Version/s: 10.3, 10.4, 10.5, 10.6, 10.7, 10.8
Fix Version/s: 10.4, 10.5, 10.6

Type: Bug Priority: Minor
Reporter: Star Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Linux



 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 dynamically update 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. Similar situations are option "slow_query_log" and table "slow_log". Similarly, the table "general_log/slow_log" should be closed when config "log_output" set into NONE or File.
(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;

suggest to fix:
when runtime change "general_log", the function fix_general_log_file will be called. Maybe we can close the table general_log during fix_general_log_file.

static bool fix_general_log_file(sys_var *self, THD *thd, enum_var_type type)
static bool fix_slow_log_file(sys_var *self, THD *thd, enum_var_type type)



 Comments   
Comment by Daniel Black [ 2022-07-11 ]

fix_log_output should also play its part if the log_output ii\s chagned.

close_log_table is the call to make.

Parachute did you want to attempt to implement this?

Comment by Star [ 2022-07-11 ]

Of course! I would attempt to implement this patch. If pass my test, I would attach it then.

Comment by Daniel Black [ 2022-07-11 ]

As a pull request would be appreciated - https://mariadb.org/get-involved/getting-started-for-developers/submitting-pull-request/

Ask on https://mariadb.zulipchat.com if you are stuck on something.

other guides which guide the contribution process.

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