Bug #101811 replication interrupted when slave restart after crash

Submitted: 1 Dec 2020 3:44 Modified: 7 Dec 2020 10:36
Reporter: long jlong (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Documentation Severity:S2 (Serious)
Version:8.0.22 OS:CentOS
Assigned to: Assigned Account CPU Architecture:Any

[1 Dec 2020 3:44] long jlong
Description:
mysql.slave_master_info may record Master_log_pos at the middle of a transaction when slave crash. Then after restart, start slave will replicate from middle of a transaction. This may report error:Duplicate entry '39408' for key 't1.PRIMARY', Error_code: 1062; handler error HA_ERR_FOUND_DUPP_KEY.

How to repeat:
1.create table t1(a int primary key); /*on master*/
2.stop slave;/*on slave*/
3.insert 100000 records into t1, every 100 records in one transaction./*master*/
4.start slave, and kill -9 slave.(we can select * from mysql.slave_master_info to check Master_log_pos)
5.start slave. /*after restart*/
6.replication will be interrupted, and report error:Duplicate entry 'xxxx' for key 't1.PRIMARY', Error_code: 1062; handler error HA_ERR_FOUND_DUPP_KEY

Suggested fix:
Master_log_pos should save the last XID_EVENT pos.
[7 Dec 2020 10:36] MySQL Verification Team
Hello long jlong,

Thank you for the report and steps.
Verified as described with 8.0.22 build.

regards,
Umesh
[7 Dec 2020 10:46] MySQL Verification Team
MySQL Server 8.0.22 test results

Attachment: 101811_8.0.22.results.txt (text/plain), 15.02 KiB.

[28 Dec 2020 16:09] Trebonius -
I was able to repro this bug too, on Ubuntu 20.04, and i tested both MyISAM and InnoDB: both seem to be affected by the issue
[14 Jul 2022 15:53] Jon Stephens
Should be Docs, not Server:RPL.

Fixed category, reassigned to myself for handling.
[1 Jun 13:47] Przemyslaw Malkowski
Still applies to 8.0.45. 
But I cannot reproduce this with relay_log_recovery=ON, so it looks like a good workaround.
Btw, I wonder why this option has not been made the default yet?

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.041 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.