Skip to content

Commit 2316a4e

Browse files
philip-galeraNirbhay Choubey
authored andcommitted
Galera MTR Tests: Tests for GRA*.log files, replication bundle, preordered events, forced binlog format
1 parent a1a7414 commit 2316a4e

12 files changed

+296
-0
lines changed

mysql-test/std_data/binlog-header.log

120 Bytes
Binary file not shown.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
START SLAVE USER='root';
2+
Warnings:
3+
Note 1759 Sending passwords in plain text without SSL/TLS is extremely insecure.
4+
CREATE TABLE ten (f1 INTEGER);
5+
INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
6+
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY AUTO_INCREMENT, f2 INTEGER) ENGINE=InnoDB;
7+
SELECT COUNT(DISTINCT f1) = 2 * 100 * 10 * 10 FROM t1;
8+
COUNT(DISTINCT f1) = 2 * 100 * 10 * 10
9+
1
10+
SELECT COUNT(*) = 2 * 100 * 10 * 10 FROM t1;
11+
COUNT(*) = 2 * 100 * 10 * 10
12+
1
13+
SELECT COUNT(DISTINCT f1) = 2 * 100 * 10 * 10 FROM t1;
14+
COUNT(DISTINCT f1) = 2 * 100 * 10 * 10
15+
1
16+
DROP TABLE t1;
17+
DROP TABLE ten;
18+
STOP SLAVE;
19+
RESET SLAVE ALL;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
START SLAVE USER='root';
2+
Warnings:
3+
Note 1759 Sending passwords in plain text without SSL/TLS is extremely insecure.
4+
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
5+
INSERT INTO t1 VALUES(1);
6+
INSERT INTO t1 VALUES(2);
7+
INSERT INTO t1 VALUES(3);
8+
INSERT INTO t1 VALUES(4);
9+
INSERT INTO t1 VALUES(5);
10+
SELECT COUNT(*) = 4 FROM t1;
11+
COUNT(*) = 4
12+
1
13+
DROP TABLE t1;
14+
STOP SLAVE;
15+
RESET SLAVE ALL;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
RESET MASTER;
2+
SET SESSION binlog_format = 'STATEMENT';
3+
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
4+
INSERT INTO t1 VALUES (1);
5+
SET SESSION binlog_format = 'MIXED';
6+
INSERT INTO t1 VALUES (2);
7+
SHOW BINLOG EVENTS IN 'mysqld-bin.000001' FROM 120;
8+
Log_name Pos Event_type Server_id End_log_pos Info
9+
mysqld-bin.000001 <Pos> Query 1 <End_log_pos> use `test`; CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB
10+
mysqld-bin.000001 <Pos> Query 1 <End_log_pos> BEGIN
11+
mysqld-bin.000001 <Pos> Table_map 1 <End_log_pos> table_id: ### (test.t1)
12+
mysqld-bin.000001 <Pos> Write_rows 1 <End_log_pos> table_id: ### flags: STMT_END_F
13+
mysqld-bin.000001 <Pos> Xid 1 <End_log_pos> COMMIT /* xid=### */
14+
mysqld-bin.000001 <Pos> Query 1 <End_log_pos> BEGIN
15+
mysqld-bin.000001 <Pos> Table_map 1 <End_log_pos> table_id: ### (test.t1)
16+
mysqld-bin.000001 <Pos> Write_rows 1 <End_log_pos> table_id: ### flags: STMT_END_F
17+
mysqld-bin.000001 <Pos> Xid 1 <End_log_pos> COMMIT /* xid=### */
18+
DROP TABLE t1;
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
SET SESSION wsrep_on=OFF;
2+
CREATE TABLE t1 (f1 INTEGER);
3+
CREATE TABLE t1 (f1 INTEGER);
4+
SELECT COUNT(*) = 0 FROM t1;
5+
COUNT(*) = 0
6+
1
7+
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
8+
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
9+
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
10+
DELIMITER /*!*/;
11+
# at 4
12+
<ISO TIMESTAMP> 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
13+
# Warning: this binlog is either in use or was not closed properly.
14+
ROLLBACK/*!*/;
15+
BINLOG '
16+
unnAVQ8CAAAAdAAAAHgAAAABAAQANS42LjI0LWRlYnVnLWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAA
17+
AAAAAAAAAAAAAAAAAAC6ecBVEzgNAAgAEgAEBAQEEgAAXAAEGggAAAAICAgCAAAACgoKGRkAAKNu
18+
Jfk=
19+
'/*!*/;
20+
# at 120
21+
<ISO TIMESTAMP> server id 1 end_log_pos 91 Query thread_id=7 exec_time=0 error_code=0
22+
use `test`/*!*/;
23+
SET TIMESTAMP=<TIMESTAMKP>/*!*/;
24+
SET @@session.pseudo_thread_id=7/*!*/;
25+
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
26+
SET @@session.sql_mode=1073741824/*!*/;
27+
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
28+
/*!\C latin1 *//*!*/;
29+
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
30+
SET @@session.lc_time_names=0/*!*/;
31+
SET @@session.collation_database=DEFAULT/*!*/;
32+
CREATE TABLE t1 (f1 INTEGER)
33+
/*!*/;
34+
DELIMITER ;
35+
# End of log file
36+
ROLLBACK /* added by mysqlbinlog */;
37+
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
38+
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;
39+
SET SESSION wsrep_on=ON;
40+
CALL mtr.add_suppression("Slave SQL: Error 'Table 't1' already exists' on query");
41+
DROP TABLE t1;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
!include ../galera_2nodes_as_slave.cnf
2+
[mysqld]
3+
wsrep-preordered=TRUE
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#
2+
# Test Galera as a slave to a MySQL master with --wsrep-preordered=TRUE
3+
#
4+
# The galera/galera_2node_slave.cnf describes the setup of the nodes
5+
#
6+
7+
--source include/have_innodb.inc
8+
--source include/have_log_bin.inc
9+
10+
# As node #1 is not a Galera node, we connect to node #2 in order to run include/galera_cluster.inc
11+
--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2
12+
--source include/galera_cluster.inc
13+
14+
--connection node_2
15+
--disable_query_log
16+
--eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$NODE_MYPORT_1;
17+
--enable_query_log
18+
START SLAVE USER='root';
19+
20+
#
21+
# Issue many large-ish transaction on the async master
22+
#
23+
24+
--connection node_1
25+
CREATE TABLE ten (f1 INTEGER);
26+
INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
27+
28+
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY AUTO_INCREMENT, f2 INTEGER) ENGINE=InnoDB;
29+
30+
--disable_query_log
31+
--let $count = 100
32+
while ($count)
33+
{
34+
--eval INSERT INTO t1 (f2) SELECT 1 FROM ten AS a1, ten AS a2;
35+
--dec $count
36+
}
37+
--enable_query_log
38+
39+
#
40+
# While the async transactions are being applied, issue another set of transactions
41+
# on the Galera node.
42+
#
43+
44+
--connection node_2
45+
--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
46+
--source include/wait_condition.inc
47+
48+
--let $count = 100
49+
--disable_query_log
50+
while ($count)
51+
{
52+
--eval INSERT INTO t1 (f2) SELECT 1 FROM ten AS a1, ten AS a2;
53+
--dec $count
54+
}
55+
--enable_query_log
56+
57+
#
58+
# Confirm that all transactions successfully committed
59+
#
60+
61+
--let $wait_condition = SELECT COUNT(*) = 2 * 100 * 10 * 10 FROM t1;
62+
--source include/wait_condition.inc
63+
64+
SELECT COUNT(DISTINCT f1) = 2 * 100 * 10 * 10 FROM t1;
65+
66+
--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3
67+
--connection node_3
68+
SELECT COUNT(*) = 2 * 100 * 10 * 10 FROM t1;
69+
SELECT COUNT(DISTINCT f1) = 2 * 100 * 10 * 10 FROM t1;
70+
71+
#
72+
# Cleanup
73+
#
74+
75+
--connection node_1
76+
DROP TABLE t1;
77+
DROP TABLE ten;
78+
79+
--connection node_2
80+
--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
81+
--source include/wait_condition.inc
82+
83+
STOP SLAVE;
84+
RESET SLAVE ALL;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
!include ../galera_2nodes_as_slave.cnf
2+
3+
[mysqld]
4+
wsrep-mysql-replication-bundle=2
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#
2+
# Test the wsrep_replication_bundle variable. We expect that multiple async replication events
3+
# will be grouped together and thus a smaller number of wsrep_last_committed transactions will
4+
# be reported.
5+
#
6+
7+
--source include/have_innodb.inc
8+
--source include/have_log_bin.inc
9+
10+
# As node #1 is not a Galera node, we connect to node #2 in order to run include/galera_cluster.inc
11+
--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2
12+
--source include/galera_cluster.inc
13+
14+
--connection node_2
15+
--disable_query_log
16+
--eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$NODE_MYPORT_1;
17+
--enable_query_log
18+
START SLAVE USER='root';
19+
20+
--connection node_1
21+
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
22+
INSERT INTO t1 VALUES(1);
23+
INSERT INTO t1 VALUES(2);
24+
INSERT INTO t1 VALUES(3);
25+
INSERT INTO t1 VALUES(4);
26+
INSERT INTO t1 VALUES(5);
27+
28+
--connection node_2
29+
--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
30+
--source include/wait_condition.inc
31+
32+
--let $wait_condition = SELECT COUNT(*) = 4 FROM t1;
33+
--source include/wait_condition.inc
34+
35+
# With wsrep_mysql_replication_bundle = 2, the last insert is not delivered
36+
# because there are not enough events remaining to complete an entire bundle
37+
SELECT COUNT(*) = 4 FROM t1;
38+
39+
# Bundle is now complete, the last INSERT and the DROP are delivered
40+
--connection node_1
41+
DROP TABLE t1;
42+
43+
--connection node_2
44+
--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
45+
--source include/wait_condition.inc
46+
47+
STOP SLAVE;
48+
RESET SLAVE ALL;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--log-bin --wsrep_forced_binlog_format=ROW

0 commit comments

Comments
 (0)