How to Resolve "Error Reading Relay Log Event" After Relay Log Corrupt...
source link: https://www.percona.com/blog/how-to-resolve-error-reading-relay-log-event-after-relay-log-corruption/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
How to Resolve "Error Reading Relay Log Event" After Relay Log Corruption
In this blog, I explain how to recover from a replication failure caused by a corrupted relay log file.
MySQL replica stores data received from its source binary log in the relay log file. This file could be corrupted due to various reasons, mostly hardware failures. If this happens, replication will stop working, and the error log on the replica will have entries similar to:
2022-05-12T12:32:07.282374Z 2 [ERROR] Error in Log_event::read_log_event(): 'Event too small', data_len: 0, event_type: 0 2022-05-12T12:32:07.282386Z 2 [ERROR] Error reading relay log event for channel '': slave SQL thread aborted because of I/O 2022-05-12T12:32:07.282396Z 2 [ERROR] Slave SQL for channel '': Relay log read failure: Could not parse relay log event entry. The possible reasons are: the master's binary log is corrupted (you can check this by running 'mysqlbinlog' on the binary log), the slave's relay log is corrupted (you can check this by running 'mysqlbinlog' on the relay log), a network problem, or a bug in the master's or slave's MySQL code. If you want to check the master's binary log or slave's relay log, you will be able to know their names by issuing 'SHOW SLAVE STATUS' on this slave. Error_code: 1594 |
Once you perform a suggested check and find that the reason for the failure was, indeed, corruption of the relay log file, you may recover replication by resetting the replica.
First, you must ensure that the source server’s binary log is not corrupted. You can do this with the help of the mysqlbinlog command. Simply run it on the binary log, and ensure it does not fail with an error.
To find out which binary log is current, run the command SHOW REPLICA STATUS (or SHOW SLAVE STATUS if you are running MySQL, older than 8.0.22).
Then find the value of Relay_Source_Log_File ( Relay_Master_Log_File ):
Relay_Source_Log_File: mysql-bin.000002 |
This will be the binary log from which the replica SQL thread executed the last statement.
Also, notice the value of the Exec_Source_Log_Pos ( Exec_Master_Log_Pos ): the latest executed position. This will be necessary for the next step.
If you are using GTIDs, you need to find the binary log that contains the last GTID in the Executed_Gtid_Set.
Once you ensure that the source’s binary log file is healthy, you can run the RESET REPLICA ( RESET SLAVE ) statement. As described at https://dev.mysql.com/doc/refman/8.0/en/reset-replica.html, “it clears the replication metadata repositories, deletes all the relay log files, and starts a new relay log file. It also resets to 0 the replication delay specified with the SOURCE_DELAY | MASTER_DELAY option of the CHANGE REPLICATION SOURCE TO statement (from MySQL 8.0.23) or CHANGE MASTER TO statement (before MySQL 8.0.23). “
Therefore you need to run the CHANGE REPLICATION SOURCE TO (or CHANGE MASTER TO ) command after it. If you use position-based replication, point the replica to the Relay_Source_Log_File and Exec_Source_Log_Pos, recorded in the previous step.
For GTID-based replicas, use SOURCE_AUTO_POSITION=1 ( MASTER_AUTO_POSITION=1 ).
Conclusion
Relay log file on the replica stores changes that could be retrieved from the source server. Therefore it is safe to remove corrupted relay log files with the help of the RESET REPLICA statement, then allow replication to reload the data from the binary log files on the source server. Mind checking if the source server did not flush the required binary logs before performing this operation.
Recommend
-
12
How to resolve ‘Login failed for user’ and sa password lost (Error 18456) This blog post explains how to get into SQL Server if you have lost your sa password or you have no way of getting into your SQL Server instance.
-
6
A Barebones Azure Event Grid to Azure Relay Listener Let’s say that you are developing with Azure Event Grid and you simply want to see the messages that it is generating to observe the schema or debug it. To do so you need t...
-
11
How to resolve an integrity error when you try to connect. (Django) advertisements when I try to log in i get an error that says
-
14
Resolve "413 Request Entity Too Large Error" on NginxHave you encountered an error “413 Request Entity Too Large Error” when trying to upload files to your website?. This often occurs when a request made by t...
-
1
Rustc Reading Club:从一个错误出发学习 rustc_resolve 发表于 2021-11-07 分类于 rust 阅读次数:84 Disqus:
-
44
-
6
Kiran Posted on Mar 29...
-
8
blog.cloudflare.com Checking if the site connection is secure
-
8
DJI has released a new firmware update for its popular Mavic Air 2 drone. Read on if you’re unable to install the new firmware package. Mavic Air 2 firmware update error...
-
1
THIS WEEK'S SPONSOR: Kolide If a device isn’t secure it can’t access your apps. It’s Dev...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK