-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MDEV-18497 CTAS async replication from mariadb master crashes galera …
…nodes (#1410) This PR contains a mtr test for reproducing a failure with replicating create table as select statement (CTAS) through asynchronous mariadb replication to mariadb galera cluster. The problem happens when CTAS replication contains both create table statement followed by row events for populating the table. In such situation, the galera node operating as mariadb replication slave, will first replicate only the create table part into the cluster, and then perform another replication containing both the create table and row events. This will lead all other nodes to fail for duplicate table create attempt, and crash due to this failure. PR contains also a fix, which identifies the situation when CTAS has been replicated, and makes further scan in async replication stream to see if there are following row events. The slave node will replicate either single TOI in case the CTAS table is empty, or if CTAS table contains rows, then single bundled write set with create table and row events is replicated to galera cluster. This fix should keep master server's GTID's for CTAS replication in sync with GTID's in galera cluster.
- Loading branch information
Showing
6 changed files
with
156 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
START SLAVE; | ||
SHOW VARIABLES LIKE 'binlog_format'; | ||
Variable_name Value | ||
binlog_format ROW | ||
CREATE TABLE source (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; | ||
CREATE TABLE target AS SELECT * FROM source; | ||
DROP TABLE target; | ||
INSERT INTO source VALUES(1); | ||
CREATE TABLE target AS SELECT * FROM source; | ||
DROP TABLE source; | ||
DROP TABLE target; | ||
STOP SLAVE; | ||
RESET SLAVE ALL; | ||
RESET MASTER; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
!include ../galera_2nodes_as_slave.cnf | ||
|
||
# make sure master server uses ROW format for replication | ||
[mysqld] | ||
binlog-format=row |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# | ||
# Test Galera as a slave to a MySQL master | ||
# | ||
# The galera/galera_2node_slave.cnf describes the setup of the nodes | ||
# also, for this test, master server must have binlog_format=ROW | ||
# | ||
|
||
--source include/have_innodb.inc | ||
|
||
# As node #1 is not a Galera node, we connect to node #2 in order to run include/galera_cluster.inc | ||
--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2 | ||
--source include/galera_cluster.inc | ||
|
||
--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3 | ||
|
||
--connection node_2 | ||
--disable_query_log | ||
--eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_USER='root', MASTER_PORT=$NODE_MYPORT_1; | ||
--enable_query_log | ||
START SLAVE; | ||
|
||
|
||
# make sure master server has binlog_format=ROW | ||
--connection node_1 | ||
SHOW VARIABLES LIKE 'binlog_format'; | ||
|
||
# | ||
# test phase one, issue CTAS with empty source table | ||
# | ||
--connection node_1 | ||
CREATE TABLE source (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; | ||
|
||
CREATE TABLE target AS SELECT * FROM source; | ||
|
||
--connection node_2 | ||
--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'target'; | ||
--source include/wait_condition.inc | ||
|
||
--connection node_3 | ||
--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'target'; | ||
--source include/wait_condition.inc | ||
|
||
# | ||
# test phase two, issue CTAS with populated source table | ||
# | ||
--connection node_1 | ||
DROP TABLE target; | ||
INSERT INTO source VALUES(1); | ||
|
||
CREATE TABLE target AS SELECT * FROM source; | ||
|
||
--connection node_2 | ||
--let $wait_condition = SELECT COUNT(*) = 1 FROM target; | ||
--source include/wait_condition.inc | ||
|
||
--connection node_3 | ||
--let $wait_condition = SELECT COUNT(*) = 1 FROM target; | ||
--source include/wait_condition.inc | ||
|
||
--connection node_1 | ||
DROP TABLE source; | ||
DROP TABLE target; | ||
|
||
--connection node_3 | ||
--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'target'; | ||
--source include/wait_condition.inc | ||
|
||
|
||
--connection node_2 | ||
STOP SLAVE; | ||
RESET SLAVE ALL; | ||
|
||
--connection node_1 | ||
RESET MASTER; | ||
--sleep 20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters