1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

MDEV-33672: 10.11 Fix for Two Phase Alter Flags

Extends 89c907bd4f 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
This commit is contained in:
Brandon Nesterenko
2024-04-09 11:35:22 -06:00
committed by Sergei Golubchik
parent 720a0f6c78
commit 8c7992165b
4 changed files with 64 additions and 1 deletions

View File

@@ -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;

View File

@@ -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

View File

@@ -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;
}

View File

@@ -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;