Bug #106002 Parallel replication with blackhole tabe on replica throws error 1863

Submitted: 29 Dec 2021 15:55 Modified: 4 Jan 2022 8:11
Reporter: Vinicius Malvestio Grippa (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Replication Severity:S2 (Serious)
Version:5.7, 5.7.36 OS:Any
Assigned to: CPU Architecture:Any

[29 Dec 2021 15:55] Vinicius Malvestio Grippa
Description:
When using InnoDB on master and Blackhole on the slave, multi-threaded replication, running a DML stops the replication with the error:

Worker 1 failed executing transaction '00046008-1111-1111-1111-111111111111:639579' at master log mysql-bin.000001, end_log_pos 536609686; Could not execute Delete_rows event on table test.bug_report; Found a row in wrong partition 0. Correct is 1 id:1614839878108305 field1:quis quisquam blanditiis omnis voluptas est est voluptatem quibusdam corporis! field2:fugiat autem voluptatem magni et. field3:expedita dicta corrupti. field4:dolores sapiente sit a suscipit. field5:2021-08-22 03:03:35, Error_code: 1863; handler error No Error!; the event's master log mysql-bin.000001, end_log_pos 536609686 | 2021-12-29 10:51:08

How to repeat:
On the source server:

CREATE TABLE `bug_report` (
`id` bigint(20) NOT NULL,
`field1` varchar(255) COLLATE utf8_bin NOT NULL,
`field2` varchar(255) COLLATE utf8_bin NOT NULL,
`field3` varchar(255) COLLATE utf8_bin NOT NULL,
`field4` varchar(255) COLLATE utf8_bin NOT NULL,
`field5` datetime NOT NULL,
PRIMARY KEY (`id`,`field1`,`field2`,`field3`,`field5`),
UNIQUE KEY `UK_blacklisted_action_type` (`field1`,`field2`,`field3`,`field5`)
) ENGINE=InnoDB AUTO_INCREMENT=29645937 DEFAULT CHARSET=utf8 COLLATE=utf8_bin
/*!50100 PARTITION BY RANGE (TO_DAYS(field5))
(PARTITION p20210701 VALUES LESS THAN (738368) ENGINE = InnoDB,
PARTITION p20210801 VALUES LESS THAN (738399) ENGINE = InnoDB,
PARTITION p20210901 VALUES LESS THAN (738429) ENGINE = InnoDB,
PARTITION p20211001 VALUES LESS THAN (738460) ENGINE = InnoDB,
PARTITION p20211101 VALUES LESS THAN (738490) ENGINE = InnoDB,
PARTITION p20211201 VALUES LESS THAN (738521) ENGINE = InnoDB,
PARTITION p20220101 VALUES LESS THAN (738552) ENGINE = InnoDB,
PARTITION p20220201 VALUES LESS THAN (738580) ENGINE = InnoDB,
PARTITION p20220301 VALUES LESS THAN (738611) ENGINE = InnoDB) */;

On the replica server:

CREATE TABLE `bug_report` (
`id` bigint(20) NOT NULL,
`field1` varchar(255) COLLATE utf8_bin NOT NULL,
`field2` varchar(255) COLLATE utf8_bin NOT NULL,
`field3` varchar(255) COLLATE utf8_bin NOT NULL,
`field4` varchar(255) COLLATE utf8_bin NOT NULL,
`field5` datetime NOT NULL
) ENGINE=BLACKHOLE DEFAULT CHARSET=utf8 COLLATE=utf8_bin
/*!50100 PARTITION BY RANGE (TO_DAYS(field5))
(PARTITION p20210701 VALUES LESS THAN (738368) ENGINE = BLACKHOLE,
PARTITION p20210801 VALUES LESS THAN (738399) ENGINE = BLACKHOLE,
PARTITION p20210901 VALUES LESS THAN (738429) ENGINE = BLACKHOLE,
PARTITION p20211001 VALUES LESS THAN (738460) ENGINE = BLACKHOLE,
PARTITION p20211101 VALUES LESS THAN (738490) ENGINE = BLACKHOLE,
PARTITION p20211201 VALUES LESS THAN (738521) ENGINE = BLACKHOLE,
PARTITION p20220101 VALUES LESS THAN (738552) ENGINE = BLACKHOLE,
PARTITION p20220201 VALUES LESS THAN (738580) ENGINE = BLACKHOLE,
PARTITION p20220301 VALUES LESS THAN (738611) ENGINE = BLACKHOLE) */;

# Loading the table with dummy data:
wget https://github.com/Percona-Lab/mysql_random_data_load/releases/download/v0.1.12/mysql_rand...
tar -xvf mysql_random_data_load_0.1.12_Linux_x86_64.tar.gz
chmod +x mysql_random_data_load

#Example
./mysql_random_data_load test bug_report 1000000 -uroot -pmsandbox -P 46008 --bulk-size=2 --max-threads=10

# run in another session in the master
delete from test.bug_report where field5 < '2022-12-25 11:00:00';

Replication will stop.

Suggested fix:
It seems that changing the slave_exec_mode to idempotent is a good workaround. The suggested fix is to automatically do this for blackhole engines.
[29 Dec 2021 19:21] MySQL Verification Team
Please provide both my.cnf.
[29 Dec 2021 19:28] Vinicius Malvestio Grippa
############ Source
[mysqld]
# basic replication options
relay-log-index=mysql-relay
relay-log=mysql-relay
log-bin=mysql-bin

# GTID options for 5.7 +
gtid_mode=ON
enforce-gtid-consistency

# replication crash-safe options
master-info-repository=table
relay-log-info-repository=table
relay-log-recovery=on

############ Replica

[mysqld]
# basic replication options
relay-log-index=mysql-relay
relay-log=mysql-relay
log-bin=mysql-bin

# GTID options for 5.7 +
gtid_mode=ON
enforce-gtid-consistency

# replication crash-safe options
master-info-repository=table
relay-log-info-repository=table
relay-log-recovery=on
slave_parallel_workers = 20
slave_parallel_type = LOGICAL_CLOCK
[4 Jan 2022 8:11] MySQL Verification Team
Hello Vinicius,

Thank you for report and feedback.
Verified as described.

regards,
Umesh
[4 Jan 2022 8:14] MySQL Verification Team
MySQL Server 5.7.36 test results

Attachment: 106002_5.7.36.results (application/octet-stream, text), 17.03 KiB.

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

Page generated in 0.054 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.