[MDEV-32664] slow log cannot be rotated Created: 2023-11-02  Updated: 2023-11-03  Resolved: 2023-11-02

Status: Closed
Project: MariaDB Server
Component/s: Admin statements
Affects Version/s: 10.6.15
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Gabriel Tziotzis Assignee: Sergei Golubchik
Resolution: Not a Bug Votes: 0
Labels: None
Environment:

Ubuntu 20.04



 Description   

I've had to enable the slow log on a production server with lots of traffic to identify some issues however it was growing really fast in size.

I decided to add logrotate to compress and rotate the slow log when it exceeded 1G but to my surprise even though it was rotated and the size appeared smaller, the disk space wasn't actually freed until maria db was restarted

It appears that maria db is holding a lock to the file indefinitely for writing without ever releasing the lock thus the operating system can never release the space that was freed from log rotation

There should either be a way to rotate it via settings or allow the operating system to free the space



 Comments   
Comment by Sergei Golubchik [ 2023-11-02 ]

it's not enough to simply move the file somewhere, you need to tell the server to reopen logs after you moved them. That's why our debian packages install a proper logrotate file into / etc/logrotate.d. You can use it as an example.

Or see https://github.com/MariaDB/server/blob/10.6/debian/mariadb-server-10.6.mysql-server.logrotate

Comment by Gabriel Tziotzis [ 2023-11-02 ]

I'll give it a try and let you know

Comment by Daniel Black [ 2023-11-03 ]

There's an updated version on https://github.com/MariaDB/server/blob/11.3/support-files/mariadb.logrotate.sh with slightly better sizing, but depends how noisy the file is.

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