You might want to use binlog compression with MySQL/Percona Server for MySQL, but it can come with drawbacks. This article discusses the need for using binlog compression and the potential issues it may cause.

Binlog compression is a technique used to reduce the size of binary log files, which can become quite large over time. This can be especially important in situations where disk space is limited. However, it’s important to be aware that using binlog compression can also cause issues with replication.

Consider the following scenario: you have restored a backup that was taken from a replica node using Percona XtraBackup. Once the restoration is complete, you want to set up replication using the information from the xtrabackup_slave_info file.

You updated the command with details for your primary and started replication.

But you have an error:

The first step is to uncompress the binlog files and start replication. If you are using general replication with binlog file and position, your replication should work well and there is no need to make any changes.

However, if you want to use GTID-based replication, the story doesn’t end there. We need to fix one more replication error.

So, what can we do to fix this?

  1. The easiest way to fix this error is to restart the primary MySQL server to update the gtid_purged variable. To do this, make sure that binlog_gtid_simple_recovery=ON is enabled.

After restarting MySQL, it will check all binlogs and update gtid_purged. To start replication on the replica node, simply execute START SLAVE;

 

Of course, this method is not for everyone, as a primary restart is not the recommended approach since it causes downtime for the entire database cluster.

  1. Another way to achieve this is by reconfiguring the replica to use the binary log file and position.

Ensure that Master_Log_File and Exec_Master_Log_Pos are present in the output of SHOW SLAVE STATUSG.

But if you don’t have it, do not despair. You can find binlogfile/position from uncompressed binlog and files using the following commands.

NOTE! – As in the output of the xtrabackup_slave_info, we have gtid_purged=00022031-1111-1111-1111-111111111111:1-31781, so we need to find the next GTID, which is 00022031-1111-1111-1111-111111111111:31782.

Go to the binlog directory on the primary node:

To find the file containing this position, run the following command:

Note: To speed up this process, please provide a good range of binlog files, such as mysql-bin.0*.

As the output of the above script, we will have binlog filename and position.

Sure thing! To solve this situation, let’s use the file mysql-bin.000053 and position 274.

We should wait until replication is fully caught up before switching back to GTID-based replication.

 

Percona Distribution for MySQL is the most complete, stable, scalable, and secure open source MySQL solution available, delivering enterprise-grade database environments for your most critical business applications… and it’s free to use!

 

Try Percona Distribution for MySQL today!

Subscribe
Notify of
guest

2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Kenny Gryp

What binlog compression is talked about here? Is this about manually compressing binlog files using gzip? Then that’s normal that things don’t work as expected.

Use binlog transaction compression instead, then these problems do not happen (https://dev.mysql.com/doc/refman/8.0/en/binary-log-transaction-compression.html). This has been released 3 years ago.