audit log rotation feature is broken as it does not happen based on size

Description

create my.cnf file

[mysqld] audit_log_filter_format=JSON audit_log_filter_max_size=102400 audit_log_filter_rotate_on_size=8196 audit_log_filter_file=mohit.log

As per settings, it is expected that audit log file must get rotated when the logsize exceeds 8KB and log pruning must happen when the total logs size(current+rotated log files) exceeds 100KB

 

It is noticed that if data is written in smaller chunks like 2KB a time, then both logfile rotation and log pruning works fine. But, if data is written in larger chunks, then all log files are pruned.

When data is written in smaller chunks into log files: (keep executing SELECT 1) 

 

-rw-r----- 1 mohit.joshi percona 8.7K Dec  2 04:34 mohit.20221202T043455.log -rw-r----- 1 mohit.joshi percona 8.7K Dec  2 04:35 mohit.20221202T043528.log -rw-r----- 1 mohit.joshi percona 8.7K Dec  2 04:35 mohit.20221202T043551.log -rw-r----- 1 mohit.joshi percona 8.7K Dec  2 04:36 mohit.20221202T043615.log -rw-r----- 1 mohit.joshi percona 8.7K Dec  2 04:36 mohit.20221202T043650.log -rw-r----- 1 mohit.joshi percona 8.7K Dec  2 04:37 mohit.20221202T043743.log -rw-r----- 1 mohit.joshi percona 8.7K Dec  2 04:38 mohit.20221202T043804.log -rw-r----- 1 mohit.joshi percona 8.7K Dec  2 04:38 mohit.20221202T043853.log -rw-r----- 1 mohit.joshi percona 8.7K Dec  2 04:39 mohit.20221202T043923.log -rw-r----- 1 mohit.joshi percona 8.7K Dec  2 04:39 mohit.20221202T043948.log -rw-r----- 1 mohit.joshi percona 8.7K Dec  2 04:41 mohit.20221202T044159.log -rw-r----- 1 mohit.joshi percona 2.0K Dec  2 04:42 mohit.log

 

When data is written in larger chunks (keep executing SHOW GLOBAL VARIABLES LIKE 'audit%'), it is noticed that 212KB is written in the current log file, which causes all the older rotated log files to be pruned

ls -lrth mohit* -rw-r----- 1 mohit.joshi percona 8.7K Dec  2 04:34 mohit.20221202T043455.log -rw-r----- 1 mohit.joshi percona 8.7K Dec  2 04:35 mohit.20221202T043528.log -rw-r----- 1 mohit.joshi percona 8.7K Dec  2 04:35 mohit.20221202T043551.log -rw-r----- 1 mohit.joshi percona 8.7K Dec  2 04:36 mohit.20221202T043615.log -rw-r----- 1 mohit.joshi percona 8.7K Dec  2 04:36 mohit.20221202T043650.log -rw-r----- 1 mohit.joshi percona 8.7K Dec  2 04:37 mohit.20221202T043743.log -rw-r----- 1 mohit.joshi percona 8.7K Dec  2 04:38 mohit.20221202T043804.log -rw-r----- 1 mohit.joshi percona 8.7K Dec  2 04:38 mohit.20221202T043853.log -rw-r----- 1 mohit.joshi percona 8.7K Dec  2 04:39 mohit.20221202T043923.log -rw-r----- 1 mohit.joshi percona 8.7K Dec  2 04:39 mohit.20221202T043948.log -rw-r----- 1 mohit.joshi percona 8.7K Dec  2 04:41 mohit.20221202T044159.log -rw-r----- 1 mohit.joshi percona 212K Dec  2 04:42 mohit.log We lost all the older rotated log files due to pruning ls -lrth mohit* -rw-r----- 1 mohit.joshi percona 2.0K Dec  2 05:15 mohit.log

 

Environment

None

Activity

Show:

mohit.joshi December 2, 2022 at 8:47 AM

Please discard this as it is not a bug.

Not a Bug

Details

Assignee

Reporter

Needs QA

Yes

Priority

Smart Checklist

Created December 2, 2022 at 5:15 AM
Updated March 6, 2024 at 9:53 AM
Resolved December 2, 2022 at 8:47 AM