0

I have a little problem and I need your help please. Here is the story : I have Percona Server in version 8.0.13 with one slave and the old binlogs on master are not deleted automatically when flush-logs appending. Variables are set as :

# mysql -e"select @@expire_logs_days, @@binlog_expire_logs_seconds"
+--------------------+------------------------------+
| @@expire_logs_days | @@binlog_expire_logs_seconds |
+--------------------+------------------------------+
|                  0 |                        86400 |
+--------------------+------------------------------+

I have logrotate which execute mysqladmin flush-logs every night and binlogs are correctly rotated but old ones are not removed. When I execute this command manually the behaviour is the same.

In MySQL CLI the command PURGE BINARY LOGS BEFORE datetime works fine.

The slave replication is up to date or a little bit late but not more than a couple hour. So it can't be explain why old binlogs are still present on disks (some are 7 days old by example)

I also execute lsof to check if MySQL retain descriptor on old binlogs but no. I have no more idea to explain the problem.

Do you have any ideas to explain and fix this please ?

Thanks,

1

Please note Paragraphs 2,3 in the MySQL Documentation for binlog_expire_logs_seconds:

The default binary log expiration period is 2592000 seconds, which equals 30 days (30*24*60*60 seconds). The default applies if neither binlog_expire_logs_seconds nor the deprecated system variable expire_logs_days has a value set at startup. If a non-zero value for one of the variables binlog_expire_logs_seconds or expire_logs_days is set at startup, this value is used as the binary log expiration period. If a non-zero value for both of those variables is set at startup, the value for binlog_expire_logs_seconds is used as the binary log expiration period, and the value for expire_logs_days is ignored with a warning message.

To disable automatic purging of the binary log, specify a value of 0 explicitly for binlog_expire_logs_seconds, and do not specify a value for expire_logs_days. For compatibility with earlier releases, automatic purging is also disabled if you specify a value of 0 explicitly for expire_logs_days and do not specify a value for binlog_expire_logs_seconds. In that case, the default for binlog_expire_logs_seconds is not applied.

Please review your my.cnf

If you have this line in the my.cnf

expire_logs_days = 0

change it to

expire_logs_days = 1

Then go execute

mysql> SET GLOBAL expire_logs_days = 1;
mysql> FLUSH BINARY LOGS;

This will cause a new thread to be opened with the new setting.

It's OK to have

expire_logs_days = 1
binlog_expire_logs_seconds = 86400

because the documentation says when both are set, binlog_expire_logs_seconds will take precedence and a simple warning is posted for expire_logs_days.

As a last resort, please restart mysql

service mysql restart

If you still have a problem after doing this, then I would suspect a bug.

|improve this answer|||||
  • 2
    Thanks RolandoMySQLDBA for your reply ! When I try to change expire_logs_days value i get an error : ERROR 3683 (HY000) at line 1: The option expire_logs_days and binlog_expire_logs_seconds cannot be used together. Please use binlog_expire_logs_seconds to set the expire time (expire_logs_days is deprecated). And I don't understand why I need to define expire_logs_days becaus the documentation says : If a non-zero value for one of the variables binlog_expire_logs_seconds or expire_logs_days is set at startup, this value is used as the binary log expiration period. – Tim Feb 17 at 7:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.