summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2022-05-18 01:23:47 +0200
committerSergei Golubchik <serg@mariadb.org>2022-05-18 01:23:47 +0200
commita0d4f0f306c6e478a1f45727e8fd9c867f9672d9 (patch)
tree88c88e6c3114afd9c111e1400563bbdddb80ff25
parentd388e7eb864a3ba677f832dff8353c55275a7942 (diff)
parent84984b79f27399d015c43a51d2b1967838119d34 (diff)
downloadmariadb-git-a0d4f0f306c6e478a1f45727e8fd9c867f9672d9.tar.gz
Merge branch '10.2' into 10.3mariadb-10.3.35
commit 84984b79f27 is null-merged
-rw-r--r--mysql-test/suite/rpl/r/rpl_gtid_glle_no_terminate.result46
-rw-r--r--mysql-test/suite/rpl/t/rpl_gtid_glle_no_terminate.test72
-rw-r--r--sql/slave.cc5
3 files changed, 121 insertions, 2 deletions
diff --git a/mysql-test/suite/rpl/r/rpl_gtid_glle_no_terminate.result b/mysql-test/suite/rpl/r/rpl_gtid_glle_no_terminate.result
new file mode 100644
index 00000000000..f4d257c2668
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_gtid_glle_no_terminate.result
@@ -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
diff --git a/mysql-test/suite/rpl/t/rpl_gtid_glle_no_terminate.test b/mysql-test/suite/rpl/t/rpl_gtid_glle_no_terminate.test
new file mode 100644
index 00000000000..f0f38a31da6
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_gtid_glle_no_terminate.test
@@ -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
diff --git a/sql/slave.cc b/sql/slave.cc
index 0ecba3c42b8..749aad5d683 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -7003,8 +7003,9 @@ dbug_gtid_accept:
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 */