Skip to content

Commit

Permalink
MDEV-33672: 10.11 Fix for Two Phase Alter Flags
Browse files Browse the repository at this point in the history
Extends 89c907b to account for
binlog_two_phase_alter flags in a Gtid log event. I.e., if the
FL_COMMIT_ALTER_E1 or FL_ROLLBACK_ALTER_E2 flags are set in the
event flags, yet the length of the event is too short to hold
the value, then set the event as invalid
  • Loading branch information
bnestere authored and vuvova committed Apr 24, 2024
1 parent 720a0f6 commit 8c79921
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 1 deletion.
24 changes: 24 additions & 0 deletions mysql-test/suite/rpl/r/rpl_gtid_header_valid.result
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
32 changes: 32 additions & 0 deletions mysql-test/suite/rpl/t/rpl_gtid_header_valid.test
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions sql/log_event.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint>(buf - buf_0) + 8)
{
seq_no= 0;
return;
}
sa_seq_no= uint8korr(buf);
buf+= 8;
}
Expand Down
4 changes: 3 additions & 1 deletion sql/log_event_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 8c79921

Please sign in to comment.