Description:
Given that different versions of MySQL may evaluate function results differently (due to bugfixes, or other unintended changes), this means that GENERATED columns on the replica might evaluate differently than on the source.
The testcase leads to replica breaking with:
[ERROR] [MY-010584] [Repl] Slave SQL for channel '': Worker 1 failed executing transaction 'e780dbec-8ac7-11ec-8ce4-902b34d12797:7' at master log fc30-bin.000002, end_log_pos 1974; Could not execute Delete_rows event on table test.t; Can't find record in 't', Error_code: 1032; Can't find record in 't', Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the event's master log fc30-bin.000002, end_log_pos 1974, Error_code: MY-001032
The source binary log contained:
#220211 1:31:04 server id 1 end_log_pos 1974 CRC32 0x8e1d285b Delete_rows: table id 112 flags: STMT_END_F
### DELETE FROM `test`.`t`
### WHERE
### @1=2 /* INT meta=0 nullable=1 is_null=0 */
### @2='߉\x12�\x1d�' /* MEDIUMBLOB/MEDIUMTEXT meta=3 nullable=1 is_null=0 */
### @3='�\x1b\x0b��\x11�\t��L�I\x03�' /* STRING(16) meta=65040 nullable=1 is_null=0 */
### DELETE FROM `test`.`t`
### WHERE
### @1=1 /* INT meta=0 nullable=1 is_null=0 */
### @2='a' /* MEDIUMBLOB/MEDIUMTEXT meta=3 nullable=1 is_null=0 */
### @3='v\x0fu5v�[\x00tu��M_�' /* STRING(16) meta=65040 nullable=1 is_null=0 */
# at 1974
It's not necessary to try matching column @3 which is the GENERATED column.
Unfortunately, due to fix of "Bug 33199145 - CONVERT(.. USING charset) gets wrong max_length" the CAST function on 8.0.28 now evaluates to NULL (it's invalid utf16), so the row isn't found. However, it's not material to the operation that the GENERATED column matches at all.
How to repeat:
Point in case:
---------------
Setup RBR replication from 8.0.27 -> 8.0.28
On Source do this:
create database if not exists test;
use test;
drop table if exists t;
create table t (
a int,
d mediumblob,
i binary(16) generated always as (unhex(md5(cast(`d` as char(3072) charset utf16)))) VIRTUAL,
key (i)
) engine=innodb;
insert into t(a,d) values(1,'a');
show warnings;
insert into t(a,d) values(2,0xDF8912DC1DFE);
show warnings; -- NO errors/warnings!
select * from t;
show warnings; -- NO warnings!
delete from t order by rand();
-- check replica status.
Suggested fix:
Please provide an option for replication applier to ignore GENERATED columns when searching for rows.