From 72776d4c49dea4848131d94af8b226a3d895514c Mon Sep 17 00:00:00 2001 From: Sachin Date: Fri, 29 May 2020 22:12:44 +0530 Subject: [PATCH] MDEV-22722 Assertion "inited==NONE" failed in handler::ha_index_init on the slave during UPDATE Add missing call for handler->prepare_for_insert() in Rows_log_event::do_apply_event --- .../main/long_unique_bugs_replication.result | 12 ++++++++++ .../main/long_unique_bugs_replication.test | 24 +++++++++++++++++++ sql/log_event_server.cc | 2 ++ 3 files changed, 38 insertions(+) create mode 100644 mysql-test/main/long_unique_bugs_replication.result create mode 100644 mysql-test/main/long_unique_bugs_replication.test diff --git a/mysql-test/main/long_unique_bugs_replication.result b/mysql-test/main/long_unique_bugs_replication.result new file mode 100644 index 0000000000000..af583d00ceafa --- /dev/null +++ b/mysql-test/main/long_unique_bugs_replication.result @@ -0,0 +1,12 @@ +include/master-slave.inc +[connection master] +create table t1 (i1 int, a1 text, unique key i1 (a1)) engine=myisam; +insert into t1 values (1,1); +insert into t1 values (2,2); +update t1 set a1 = 'd' limit 1; +update t1 set a1 = 'd2' where i1= 2; +connection slave; +connection slave; +connection master; +drop table t1; +include/rpl_end.inc diff --git a/mysql-test/main/long_unique_bugs_replication.test b/mysql-test/main/long_unique_bugs_replication.test new file mode 100644 index 0000000000000..1cacd088bee6d --- /dev/null +++ b/mysql-test/main/long_unique_bugs_replication.test @@ -0,0 +1,24 @@ +# +# Long unique bugs related to master slave replication +# + +# +# MDEV-22722 Assertion "inited==NONE" failed in handler::ha_index_init on the slave during UPDATE +# + +--source include/have_binlog_format_row.inc +--source include/master-slave.inc + +create table t1 (i1 int, a1 text, unique key i1 (a1)) engine=myisam; +insert into t1 values (1,1); +insert into t1 values (2,2); +update t1 set a1 = 'd' limit 1; +update t1 set a1 = 'd2' where i1= 2; + +sync_slave_with_master; +connection slave; + +connection master; +drop table t1; + +--source include/rpl_end.inc diff --git a/sql/log_event_server.cc b/sql/log_event_server.cc index 5910ece12f073..f59c8110e51ed 100644 --- a/sql/log_event_server.cc +++ b/sql/log_event_server.cc @@ -5570,6 +5570,8 @@ int Rows_log_event::do_apply_event(rpl_group_info *rgi) { master_had_triggers= table->master_had_triggers; bool transactional_table= table->file->has_transactions_and_rollback(); + table->file->prepare_for_insert(get_genral_type_code() != WRITE_ROWS_EVENT); + /* table == NULL means that this table should not be replicated (this was set up by Table_map_log_event::do_apply_event()