简体   繁体   中英

Transaction inconsistencies on slave mysql GTID replication

A slave failed the replication of a query and stopped working. I performed a fresh database dump on the master mysql server with --databases myapp to only include the one database that is supposed to be replicated. This is because on the slave I have other apps databases running that should be isolated from replication.

The latest command i tried is mysqldump --databases myapp --flush-privileges --single-transaction --flush-logs --triggers --routines --events > dump.sql

After the database has been freshly imported and the slave is reset and started once again, it continuously fails every 1-20th transaction due to inconsistencies. Deletes/Updates fail.

Some of the error messages are:

Could not execute Write_rows event on table myapp.table; Duplicate entry '378483-1195430' for key 'unique', Error_code: 1062; handler error HA_ERR_FOUND_DUPP_KEY; the event's master log mysql-bin.096490, end_log_pos 82577698

Could not execute Update_rows event on table myapp.table; Can't find record in 'table', Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the event's master log mysql-bin.096136, end_log_pos 648509

Even when purging mysql and reinstalling mysql, the problem persists. Only on a freshly setup vm, it seems to accept the database dump.

My feeling is that there is some residue from the previous replication that interferes. I tried to run mysqldump with different combinations of arguments, none help so far. I also flushed the mysql.gtid_executed table manually, but the problem does not go away.

Which steps do i have to undertake to reset the mysql instance into a neutral state where i can restart the gtid slave replication?

The OS is ubuntu 18.04, mysql version is 5.7 on both master and slave.

The answer was, that GLOBAL.gtid_purged and GLOBAL.gtid_executed dont reset unless you also execute reset master; which is a bit counterintuitive on a mysql instance that is only a slave, but that empties those two global variables and if the mysqldump is made with --set-gtid-purged=on , it sets the correct values too.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM