Skip to content

Commit

Permalink
Merge branch '10.2' into 10.3
Browse files Browse the repository at this point in the history
  • Loading branch information
vuvova committed May 13, 2022
2 parents 2cde995 + 2d26f71 commit 5c5cd0e
Show file tree
Hide file tree
Showing 3 changed files with 121 additions and 2 deletions.
46 changes: 46 additions & 0 deletions mysql-test/suite/rpl/r/rpl_gtid_glle_no_terminate.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
include/master-slave.inc
[connection master]
connection slave;
include/stop_slave.inc
CHANGE MASTER TO MASTER_USE_GTID=slave_pos;
#
# Initialize test data
connection master;
create table t1 (a int);
SET @@session.server_id= 3;
create table t2 (a int);
include/save_master_gtid.inc
#
# Have the replica "reconnect" and the primary will send Gtid, Glle, DDL
connection slave;
set global gtid_slave_pos="0-3-1";
include/start_slave.inc
include/sync_with_master_gtid.inc
#
# Ensure that the replica did not error
connection slave;
include/sync_with_master_gtid.inc
Last_SQL_Error =
Last_SQL_Errno = 0
#
# Ensure that the primary sent a Glle after a Gtid event
include/show_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
slave-relay-bin.000002 # Rotate # # master-bin.000001;pos=POS
slave-relay-bin.000002 # Format_desc # # SERVER_VERSION, BINLOG_VERSION
slave-relay-bin.000002 # Gtid_list # # []
slave-relay-bin.000002 # Binlog_checkpoint # # master-bin.000001
slave-relay-bin.000002 # Gtid # # GTID #-#-#
slave-relay-bin.000002 # Gtid_list # # [#-#-#]
slave-relay-bin.000002 # Query # # use `test`; create table t2 (a int)
#
# Ensure the DDL was executed on the replica
#
# Cleanup
# t1 does not make it to the replica
connection master;
set sql_log_bin=0;
DROP TABLE t1;
set sql_log_bin=1;
DROP TABLE t2;
include/rpl_end.inc
72 changes: 72 additions & 0 deletions mysql-test/suite/rpl/t/rpl_gtid_glle_no_terminate.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#
# Purpose:
# If a fake Glle event follows a Gtid event, we need to ensure the rest of
# the group should not terminate at the Glle event. MDEV-28550 revealed that
# a Glle would terminate the event and upon reconnect, the DDL would be lost.
#
# Methodology:
# Force the primary to send a fake GLLE event after a GTID on a "reconnect"
# and ensure that both 1) the replica does not error, and 2) the original
# command within the GTID is executed.
#
# References:
# MDEV-28550: improper handling of replication event group that contains Gtid_log_list_event

--source include/master-slave.inc

# Independent of binlog format
--source include/have_binlog_format_statement.inc

--connection slave
--source include/stop_slave.inc
CHANGE MASTER TO MASTER_USE_GTID=slave_pos;

--echo #
--echo # Initialize test data
--connection master
create table t1 (a int);
SET @@session.server_id= 3;
create table t2 (a int);
--source include/save_master_gtid.inc

--echo #
--echo # Have the replica "reconnect" and the primary will send Gtid, Glle, DDL
--connection slave
eval set global gtid_slave_pos="0-3-1";
--source include/start_slave.inc
--source include/sync_with_master_gtid.inc

--echo #
--echo # Ensure that the replica did not error
connection slave;
--source include/sync_with_master_gtid.inc
let $error= query_get_value(SHOW SLAVE STATUS, Last_SQL_Error, 1);
--echo Last_SQL_Error = $error
let $errno= query_get_value(SHOW SLAVE STATUS, Last_SQL_Errno, 1);
--echo Last_SQL_Errno = $errno

--echo #
--echo # Ensure that the primary sent a Glle after a Gtid event
let $binlog_file= query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 1);
let $binlog_start= $relaylog_start;
let $binlog_limit=0,10;
--source include/show_relaylog_events.inc

--echo #
--echo # Ensure the DDL was executed on the replica
if (!`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't2'`)
{
die "t2 should exist on slave";
}

--echo #
--echo # Cleanup

--echo # t1 does not make it to the replica
--connection master
set sql_log_bin=0;
DROP TABLE t1;
set sql_log_bin=1;
DROP TABLE t2;

--source include/rpl_end.inc
5 changes: 3 additions & 2 deletions sql/slave.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7003,8 +7003,9 @@ static int queue_event(Master_info* mi,const char* buf, ulong event_len)
mi->using_gtid != Master_info::USE_GTID_NO &&
mi->events_queued_since_last_gtid > 0 &&
( (mi->last_queued_gtid_standalone &&
!Log_event::is_part_of_group((Log_event_type)(uchar)
buf[EVENT_TYPE_OFFSET])) ||
(LOG_EVENT_IS_QUERY((Log_event_type)(uchar)
buf[EVENT_TYPE_OFFSET]) ||
(uchar)buf[EVENT_TYPE_OFFSET] == INCIDENT_EVENT)) ||
(!mi->last_queued_gtid_standalone &&
((uchar)buf[EVENT_TYPE_OFFSET] == XID_EVENT ||
((uchar)buf[EVENT_TYPE_OFFSET] == QUERY_EVENT && /* QUERY_COMPRESSED_EVENT would never be commmit or rollback */
Expand Down

0 comments on commit 5c5cd0e

Please sign in to comment.