diff --git a/mysql-test/std_data/binlog-header.log b/mysql-test/std_data/binlog-header.log new file mode 100644 index 00000000000..c415a57e616 Binary files /dev/null and b/mysql-test/std_data/binlog-header.log differ diff --git a/mysql-test/suite/galera/r/galera_as_slave_preordered.result b/mysql-test/suite/galera/r/galera_as_slave_preordered.result new file mode 100644 index 00000000000..27a08e73491 --- /dev/null +++ b/mysql-test/suite/galera/r/galera_as_slave_preordered.result @@ -0,0 +1,19 @@ +START SLAVE USER='root'; +Warnings: +Note 1759 Sending passwords in plain text without SSL/TLS is extremely insecure. +CREATE TABLE ten (f1 INTEGER); +INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY AUTO_INCREMENT, f2 INTEGER) ENGINE=InnoDB; +SELECT COUNT(DISTINCT f1) = 2 * 100 * 10 * 10 FROM t1; +COUNT(DISTINCT f1) = 2 * 100 * 10 * 10 +1 +SELECT COUNT(*) = 2 * 100 * 10 * 10 FROM t1; +COUNT(*) = 2 * 100 * 10 * 10 +1 +SELECT COUNT(DISTINCT f1) = 2 * 100 * 10 * 10 FROM t1; +COUNT(DISTINCT f1) = 2 * 100 * 10 * 10 +1 +DROP TABLE t1; +DROP TABLE ten; +STOP SLAVE; +RESET SLAVE ALL; diff --git a/mysql-test/suite/galera/r/galera_as_slave_replication_bundle.result b/mysql-test/suite/galera/r/galera_as_slave_replication_bundle.result new file mode 100644 index 00000000000..a86bfd20e2f --- /dev/null +++ b/mysql-test/suite/galera/r/galera_as_slave_replication_bundle.result @@ -0,0 +1,15 @@ +START SLAVE USER='root'; +Warnings: +Note 1759 Sending passwords in plain text without SSL/TLS is extremely insecure. +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES(1); +INSERT INTO t1 VALUES(2); +INSERT INTO t1 VALUES(3); +INSERT INTO t1 VALUES(4); +INSERT INTO t1 VALUES(5); +SELECT COUNT(*) = 4 FROM t1; +COUNT(*) = 4 +1 +DROP TABLE t1; +STOP SLAVE; +RESET SLAVE ALL; diff --git a/mysql-test/suite/galera/r/galera_forced_binlog_format.result b/mysql-test/suite/galera/r/galera_forced_binlog_format.result new file mode 100644 index 00000000000..857e44d2dfc --- /dev/null +++ b/mysql-test/suite/galera/r/galera_forced_binlog_format.result @@ -0,0 +1,18 @@ +RESET MASTER; +SET SESSION binlog_format = 'STATEMENT'; +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +SET SESSION binlog_format = 'MIXED'; +INSERT INTO t1 VALUES (2); +SHOW BINLOG EVENTS IN 'mysqld-bin.000001' FROM 120; +Log_name Pos Event_type Server_id End_log_pos Info +mysqld-bin.000001 Query 1 use `test`; CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB +mysqld-bin.000001 Query 1 BEGIN +mysqld-bin.000001 Table_map 1 table_id: ### (test.t1) +mysqld-bin.000001 Write_rows 1 table_id: ### flags: STMT_END_F +mysqld-bin.000001 Xid 1 COMMIT /* xid=### */ +mysqld-bin.000001 Query 1 BEGIN +mysqld-bin.000001 Table_map 1 table_id: ### (test.t1) +mysqld-bin.000001 Write_rows 1 table_id: ### flags: STMT_END_F +mysqld-bin.000001 Xid 1 COMMIT /* xid=### */ +DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/galera_gra_log.result b/mysql-test/suite/galera/r/galera_gra_log.result new file mode 100644 index 00000000000..e98eaee8cc8 --- /dev/null +++ b/mysql-test/suite/galera/r/galera_gra_log.result @@ -0,0 +1,41 @@ +SET SESSION wsrep_on=OFF; +CREATE TABLE t1 (f1 INTEGER); +CREATE TABLE t1 (f1 INTEGER); +SELECT COUNT(*) = 0 FROM t1; +COUNT(*) = 0 +1 +/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; +/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; +DELIMITER /*!*/; +# at 4 + server id 2 end_log_pos 120 Start: binlog v 4, server v 5.6.24-debug-log created 150804 11:37:14 at startup +# Warning: this binlog is either in use or was not closed properly. +ROLLBACK/*!*/; +BINLOG ' +unnAVQ8CAAAAdAAAAHgAAAABAAQANS42LjI0LWRlYnVnLWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAC6ecBVEzgNAAgAEgAEBAQEEgAAXAAEGggAAAAICAgCAAAACgoKGRkAAKNu +Jfk= +'/*!*/; +# at 120 + server id 1 end_log_pos 91 Query thread_id=7 exec_time=0 error_code=0 +use `test`/*!*/; +SET TIMESTAMP=/*!*/; +SET @@session.pseudo_thread_id=7/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; +SET @@session.sql_mode=1073741824/*!*/; +SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; +/*!\C latin1 *//*!*/; +SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; +SET @@session.lc_time_names=0/*!*/; +SET @@session.collation_database=DEFAULT/*!*/; +CREATE TABLE t1 (f1 INTEGER) +/*!*/; +DELIMITER ; +# End of log file +ROLLBACK /* added by mysqlbinlog */; +/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; +/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/; +SET SESSION wsrep_on=ON; +CALL mtr.add_suppression("Slave SQL: Error 'Table 't1' already exists' on query"); +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_as_slave_preordered.cnf b/mysql-test/suite/galera/t/galera_as_slave_preordered.cnf new file mode 100644 index 00000000000..d1a0fb15ff3 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_as_slave_preordered.cnf @@ -0,0 +1,3 @@ +!include ../galera_2nodes_as_slave.cnf +[mysqld] +wsrep-preordered=TRUE diff --git a/mysql-test/suite/galera/t/galera_as_slave_preordered.test b/mysql-test/suite/galera/t/galera_as_slave_preordered.test new file mode 100644 index 00000000000..6f221f83b3a --- /dev/null +++ b/mysql-test/suite/galera/t/galera_as_slave_preordered.test @@ -0,0 +1,84 @@ +# +# Test Galera as a slave to a MySQL master with --wsrep-preordered=TRUE +# +# The galera/galera_2node_slave.cnf describes the setup of the nodes +# + +--source include/have_innodb.inc +--source include/have_log_bin.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 + +--connection node_2 +--disable_query_log +--eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$NODE_MYPORT_1; +--enable_query_log +START SLAVE USER='root'; + +# +# Issue many large-ish transaction on the async master +# + +--connection node_1 +CREATE TABLE ten (f1 INTEGER); +INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); + +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY AUTO_INCREMENT, f2 INTEGER) ENGINE=InnoDB; + +--disable_query_log +--let $count = 100 +while ($count) +{ + --eval INSERT INTO t1 (f2) SELECT 1 FROM ten AS a1, ten AS a2; + --dec $count +} +--enable_query_log + +# +# While the async transactions are being applied, issue another set of transactions +# on the Galera node. +# + +--connection node_2 +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; +--source include/wait_condition.inc + +--let $count = 100 +--disable_query_log +while ($count) +{ + --eval INSERT INTO t1 (f2) SELECT 1 FROM ten AS a1, ten AS a2; + --dec $count +} +--enable_query_log + +# +# Confirm that all transactions successfully committed +# + +--let $wait_condition = SELECT COUNT(*) = 2 * 100 * 10 * 10 FROM t1; +--source include/wait_condition.inc + +SELECT COUNT(DISTINCT f1) = 2 * 100 * 10 * 10 FROM t1; + +--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3 +--connection node_3 +SELECT COUNT(*) = 2 * 100 * 10 * 10 FROM t1; +SELECT COUNT(DISTINCT f1) = 2 * 100 * 10 * 10 FROM t1; + +# +# Cleanup +# + +--connection node_1 +DROP TABLE t1; +DROP TABLE ten; + +--connection node_2 +--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; +--source include/wait_condition.inc + +STOP SLAVE; +RESET SLAVE ALL; diff --git a/mysql-test/suite/galera/t/galera_as_slave_replication_bundle.cnf b/mysql-test/suite/galera/t/galera_as_slave_replication_bundle.cnf new file mode 100644 index 00000000000..d092d88bfaf --- /dev/null +++ b/mysql-test/suite/galera/t/galera_as_slave_replication_bundle.cnf @@ -0,0 +1,4 @@ +!include ../galera_2nodes_as_slave.cnf + +[mysqld] +wsrep-mysql-replication-bundle=2 diff --git a/mysql-test/suite/galera/t/galera_as_slave_replication_bundle.test b/mysql-test/suite/galera/t/galera_as_slave_replication_bundle.test new file mode 100644 index 00000000000..f873294143e --- /dev/null +++ b/mysql-test/suite/galera/t/galera_as_slave_replication_bundle.test @@ -0,0 +1,48 @@ +# +# Test the wsrep_replication_bundle variable. We expect that multiple async replication events +# will be grouped together and thus a smaller number of wsrep_last_committed transactions will +# be reported. +# + +--source include/have_innodb.inc +--source include/have_log_bin.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 + +--connection node_2 +--disable_query_log +--eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$NODE_MYPORT_1; +--enable_query_log +START SLAVE USER='root'; + +--connection node_1 +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES(1); +INSERT INTO t1 VALUES(2); +INSERT INTO t1 VALUES(3); +INSERT INTO t1 VALUES(4); +INSERT INTO t1 VALUES(5); + +--connection node_2 +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; +--source include/wait_condition.inc + +--let $wait_condition = SELECT COUNT(*) = 4 FROM t1; +--source include/wait_condition.inc + +# With wsrep_mysql_replication_bundle = 2, the last insert is not delivered +# because there are not enough events remaining to complete an entire bundle +SELECT COUNT(*) = 4 FROM t1; + +# Bundle is now complete, the last INSERT and the DROP are delivered +--connection node_1 +DROP TABLE t1; + +--connection node_2 +--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; +--source include/wait_condition.inc + +STOP SLAVE; +RESET SLAVE ALL; diff --git a/mysql-test/suite/galera/t/galera_forced_binlog_format-master.opt b/mysql-test/suite/galera/t/galera_forced_binlog_format-master.opt new file mode 100644 index 00000000000..8c58b59b45d --- /dev/null +++ b/mysql-test/suite/galera/t/galera_forced_binlog_format-master.opt @@ -0,0 +1 @@ +--log-bin --wsrep_forced_binlog_format=ROW diff --git a/mysql-test/suite/galera/t/galera_forced_binlog_format.test b/mysql-test/suite/galera/t/galera_forced_binlog_format.test new file mode 100644 index 00000000000..934c15399e0 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_forced_binlog_format.test @@ -0,0 +1,25 @@ +# +# Test that wsrep_forced_binlog_format=ROW indeed prevents the log to be switched to STATEMENT format on a per-connection basis +# + +--source include/have_log_bin.inc +--source include/have_innodb.inc +--source include/galera_cluster.inc + +--connection node_1 +RESET MASTER; + +SET SESSION binlog_format = 'STATEMENT'; + +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); + +SET SESSION binlog_format = 'MIXED'; + +INSERT INTO t1 VALUES (2); + +--replace_regex /xid=[0-9]+/xid=###/ /table_id: [0-9]+/table_id: ###/ +--replace_column 2 5 +SHOW BINLOG EVENTS IN 'mysqld-bin.000001' FROM 120; + +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_gra_log.test b/mysql-test/suite/galera/t/galera_gra_log.test new file mode 100644 index 00000000000..f666920b2cf --- /dev/null +++ b/mysql-test/suite/galera/t/galera_gra_log.test @@ -0,0 +1,38 @@ +# +# Test that GRA_* files are generated on applier failure and are readable. +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +--connection node_2 +--exec rm -rf $MYSQLTEST_VARDIR/mysqld.2/data/GRA_*.log + +# Create applier failure + +SET SESSION wsrep_on=OFF; +CREATE TABLE t1 (f1 INTEGER); + +--connection node_1 +CREATE TABLE t1 (f1 INTEGER); + +--connection node_2 +SELECT COUNT(*) = 0 FROM t1; + +# Compose a valid binlog from a header file and the GRA file + +--let $gra_binlog_file = $MYSQLTEST_VARDIR/tmp/gra.log +--exec rm -rf $gra_binlog_file + +--exec cp std_data/binlog-header.log $gra_binlog_file +--exec cat $MYSQLTEST_VARDIR/mysqld.2/data/GRA_*.log >> $gra_binlog_file + +# Make sure the binlog thus produced is readable and contains the failure +--replace_regex /SET TIMESTAMP=[0-9]+/SET TIMESTAMP=/ /#[0-9]+ [0-9]+:[0-9]+:[0-9]+// +--exec $MYSQL_BINLOG $gra_binlog_file + +SET SESSION wsrep_on=ON; + +CALL mtr.add_suppression("Slave SQL: Error 'Table 't1' already exists' on query"); + +DROP TABLE t1;