diff --git a/mysql-test/suite/rpl/r/rpl_gtid_header_valid.result b/mysql-test/suite/rpl/r/rpl_gtid_header_valid.result index fd440feb3c9..6731abc27b7 100644 --- a/mysql-test/suite/rpl/r/rpl_gtid_header_valid.result +++ b/mysql-test/suite/rpl/r/rpl_gtid_header_valid.result @@ -112,6 +112,30 @@ RESET MASTER; set @@global.gtid_slave_pos=""; include/start_slave.inc # +# Test FL_COMMIT_ALTER +connection master; +set @old_dbug= @@SESSION.debug_dbug; +set @@SESSION.debug_dbug= "+d,negate_alter_fl_from_gtid"; +set @old_alter_tp= @@SESSION.binlog_alter_two_phase; +set @@SESSION.binlog_alter_two_phase= 1; +alter table t1 add column (nc int); +include/save_master_gtid.inc +set @@SESSION.debug_dbug=@old_dbug; +set @@SESSION.binlog_alter_two_phase=@old_alter_tp; +connection slave; +# Waiting for slave to find invalid event.. +include/wait_for_slave_sql_error.inc [errno=1594] +STOP SLAVE IO_THREAD; +# Reset master binlogs (as there is an invalid event) and slave state +connection master; +RESET MASTER; +connection slave; +SET STATEMENT sql_log_bin=0 FOR alter table t1 add column (nc int); +RESET SLAVE; +RESET MASTER; +set @@global.gtid_slave_pos=""; +include/start_slave.inc +# # Cleanup connection master; drop table t1; diff --git a/mysql-test/suite/rpl/t/rpl_gtid_header_valid.test b/mysql-test/suite/rpl/t/rpl_gtid_header_valid.test index db546787914..d4d75ba8928 100644 --- a/mysql-test/suite/rpl/t/rpl_gtid_header_valid.test +++ b/mysql-test/suite/rpl/t/rpl_gtid_header_valid.test @@ -167,6 +167,38 @@ RESET MASTER; set @@global.gtid_slave_pos=""; --source include/start_slave.inc + +--echo # +--echo # Test FL_COMMIT_ALTER +--connection master +set @old_dbug= @@SESSION.debug_dbug; +set @@SESSION.debug_dbug= "+d,negate_alter_fl_from_gtid"; +set @old_alter_tp= @@SESSION.binlog_alter_two_phase; +set @@SESSION.binlog_alter_two_phase= 1; +alter table t1 add column (nc int); +--source include/save_master_gtid.inc +set @@SESSION.debug_dbug=@old_dbug; +set @@SESSION.binlog_alter_two_phase=@old_alter_tp; + +--connection slave +--echo # Waiting for slave to find invalid event.. +let $slave_sql_errno= 1594; # ER_SLAVE_RELAY_LOG_READ_FAILURE +source include/wait_for_slave_sql_error.inc; +STOP SLAVE IO_THREAD; + +--echo # Reset master binlogs (as there is an invalid event) and slave state +--connection master +RESET MASTER; + +--connection slave +# Just to keep tables consistent between master/slave +SET STATEMENT sql_log_bin=0 FOR alter table t1 add column (nc int); +RESET SLAVE; +RESET MASTER; +set @@global.gtid_slave_pos=""; +--source include/start_slave.inc + + --echo # --echo # Cleanup diff --git a/sql/log_event.cc b/sql/log_event.cc index bf3d93c903d..09a11219949 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -2688,6 +2688,11 @@ Gtid_log_event::Gtid_log_event(const uchar *buf, uint event_len, } if (flags_extra & (FL_COMMIT_ALTER_E1 | FL_ROLLBACK_ALTER_E1)) { + if (event_len < static_cast(buf - buf_0) + 8) + { + seq_no= 0; + return; + } sa_seq_no= uint8korr(buf); buf+= 8; } diff --git a/sql/log_event_server.cc b/sql/log_event_server.cc index 6b72efdd206..003774c24aa 100644 --- a/sql/log_event_server.cc +++ b/sql/log_event_server.cc @@ -3759,7 +3759,9 @@ Gtid_log_event::write() write_len++; } - if (flags_extra & (FL_COMMIT_ALTER_E1 | FL_ROLLBACK_ALTER_E1)) + if (flags_extra & (FL_COMMIT_ALTER_E1 | FL_ROLLBACK_ALTER_E1) + && !DBUG_IF("negate_alter_fl_from_gtid") + ) { int8store(buf + write_len, sa_seq_no); write_len+= 8;