summaryrefslogtreecommitdiff
path: root/mysql-test/suite/galera/t/galera_as_slave_gtid_replicate_do_db.test
blob: 81b6d446ba66c376059729417839d174e9460840 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#
# Test Galera as a slave to a MySQL master using GTIDs
#

--source include/have_innodb.inc
--source include/galera_cluster.inc
--source include/have_log_bin.inc

# As node #3 is not a Galera node, and galera_cluster.inc does not open connetion to it
# we open the node_3 connection here
--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3

--connection node_1
SET global wsrep_on=OFF;
RESET MASTER;
SET global wsrep_on=ON;

--connection node_3
RESET MASTER;

--connection node_2
SET global wsrep_on=OFF;
RESET MASTER;
SET global wsrep_on=ON;
--disable_query_log
--eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$NODE_MYPORT_3, MASTER_USER='root';
--enable_query_log
START SLAVE;

--connection node_3
CREATE SCHEMA test1;
CREATE SCHEMA test2;
USE test1;
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY,f2 CHAR(5) DEFAULT 'abc') ENGINE=InnoDB;
USE test2;
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY,f2 CHAR(5) DEFAULT 'abc') ENGINE=InnoDB;

#
# First , some autocommit stuff
#

# Simple inserts

INSERT INTO test1.t1 (f1) VALUES (1);
INSERT INTO test2.t1 (f1) VALUES (1);

INSERT INTO test1.t1 (f1) VALUES (2);
INSERT INTO test2.t1 (f1) VALUES (2);

INSERT INTO test1.t1 (f1) VALUES (3);
INSERT INTO test2.t1 (f1) VALUES (3);

# Update that only covers test2.t1

UPDATE test2.t1 SET test2.t1.f2 = 'cde';

# Multi-table UPDATE

UPDATE test1.t1, test2.t1 SET test1.t1.f2 = 'klm', test2.t1.f2 = 'xyz';

# Multi-table DELETE

DELETE test1.t1, test2.t1 FROM test1.t1 INNER JOIN test2.t1 WHERE test1.t1.f1 = test2.t1.f1 AND test1.t1.f1 = 3;

#
# Multi-statement transactions
#

# Transaction which is not replicated at all

SET AUTOCOMMIT=OFF;
START TRANSACTION;
INSERT INTO test2.t1 (f1) VALUES (999);
INSERT INTO test2.t1 (f1) VALUES (9999);
COMMIT;

# Transaction that is completely replicated
START TRANSACTION;
INSERT INTO test1.t1 (f1) VALUES (111);
INSERT INTO test1.t1 (f1) VALUES (222);
COMMIT;

# Transaction that is partially replicated

START TRANSACTION;
INSERT INTO test1.t1 (f1) VALUES (333);
INSERT INTO test2.t1 (f1) VALUES (99999);
COMMIT;

#
# Make sure binary logs and gtid_executed strings are equal
#

--sleep 2
--connection node_2
--let $effective_uuid = `SELECT LEFT(@@global.gtid_current_pos, 36)`
--let $gtid_executed_node2 = `SELECT @@global.gtid_current_pos;`

--replace_result $effective_uuid <effective_uuid>
--replace_regex /xid=[0-9]+/xid=###/ /table_id: [0-9]+/table_id: ###/
SHOW BINLOG EVENTS IN 'master-bin.000001' FROM 256;

--connection node_1

--disable_query_log
--eval SELECT '$gtid_executed_node2' = @@global.gtid_current_pos AS gtid_executed_equal;
--enable_query_log

--replace_result $effective_uuid <effective_uuid>
--replace_regex /xid=[0-9]+/xid=###/ /table_id: [0-9]+/table_id: ###/
SHOW BINLOG EVENTS IN 'master-bin.000001' FROM 256;

#
# Final consistency checks
# 

--let $diff_servers = 1 2
--source include/diff_servers.inc

--connection node_1
--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
--source include/wait_condition.inc

SELECT COUNT(*) = 2 FROM test1.t1 WHERE f1 IN (1,2);
SELECT COUNT(*) = 3 FROM test1.t1 WHERE f1 IN (111,222,333);
SELECT COUNT(*) = 2 FROM test1.t1 WHERE f2 = 'klm';

--error 1049
USE test2;

#
# Cleanup
#

--connection node_3
DROP SCHEMA test1;
DROP SCHEMA test2;

--sleep 1

--connection node_1
--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
--source include/wait_condition.inc

--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;