Score:0

why mysql bin logs are not expiring even though expiry was set

tl flag

I am using 5.7.37-log MySQL Community Server. my mysqld.cnf looks below:

server_id = 11
log_bin = bin.log
log-bin-index = bin-log.index
binlog_format = row
max_binlog_size = 100M
socket = mysql.sock
expire_logs_days = 1

when i check my logs they keep on growing though i mention them to get expire in 1 day. using expire_logs_days.

With this above config, can i expect the logs be removed automatically or should I again do it manually ? I see some forms saying PURGE BINARY LOGS BEFORE NOW() - INTERVAL 1 DAY; But i dont understand the point in manually running above statement when we already set the config.

Please help me understanding the expiry mechanism of bin logs. As I used expiry after 1 day, does the size of the bin.00001 and bin.0002 etc. will be reduded every day ? or how can i identify that the logs are really expiring.?

attaching screenshot of my generated bin logs.

enter image description here

djdomi avatar
za flag
I would suggest that you take a look at [dba.se] which might be more fitting for your question and is for enthusiastic administrators
ua flag
I think that it will purge 000001 when the next one starts, namely 000004. Meanwhile, note that 000003 is only 15% 'full' so far.
santhosh avatar
tl flag
@RickJames but then i dont see the use of expire_logs_days = 1. it should purge logs after 1 day irrespective of the log size. But I also observed the old log files getting removed when i do mysql restart. but restarting mysql everytime to remove old logs is not a good idea..
ua flag
Please report on what happens after the server stays up long enough to exceed 100M in one binlog.
Score:1
tr flag

There is no timer that runs and deletes logs after one day. Log deletion is triggered by log flush events. So that is when a new binlog is generated. If it takes too long on our database and logs are not flushed daily the you could set max-binlog-size to a lower value. Another good option would be to always flush logs as part of your backup strategy.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.