summaryrefslogtreecommitdiff
path: root/mysql-test/suite/rpl/t/rpl_gtid_stop_start.test
blob: cc1da6b3c852c5146151ce8ee2a9537da846fe7a (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
--let $rpl_topology=1->2
--source include/rpl_init.inc

--echo *** Test normal shutdown/restart of slave server configured as a GTID slave. ***

--connection server_1
CREATE TABLE t1 (a INT PRIMARY KEY);
INSERT INTO t1 VALUES (1);
--save_master_pos

--connection server_2
--sync_with_master
--source include/stop_slave.inc

--let $status_items= Master_Log_File,Using_Gtid
--source include/show_slave_status.inc

CHANGE MASTER TO master_use_gtid=current_pos;

# Now try to restart the slave mysqld server without starting the slave first
# threads after the CHANGE MASTER.
# When the slave restarts, it should reconnect using GTID.
# We test that it really uses GTID by purging on the master the
# old binlog the slave would need if connecting with old style
# file name/offset.

--write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
wait
EOF
--shutdown_server 30
--source include/wait_until_disconnected.inc

--connection server_1
FLUSH LOGS;
--let $purge_binlogs_to=master-bin.000002
--source include/wait_for_purge.inc
--source include/show_binary_logs.inc
INSERT INTO t1 VALUES (2);
FLUSH LOGS;
INSERT INTO t1 VALUES (3);
--source include/show_binary_logs.inc

# Let the slave mysqld server start again.
--append_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
restart: --skip-slave-start=0
EOF

--connection server_2
--enable_reconnect
--source include/wait_until_connected_again.inc

--let $wait_condition= SELECT COUNT(*) = 3 FROM t1
--source include/wait_condition.inc
SELECT * FROM t1 ORDER BY a;


--echo *** Test normal shutdown/restart of master server, check binlog state is preserved. ***

--connection server_1
SET SESSION gtid_domain_id= 1;
INSERT INTO t1 VALUES (4);
--replace_column 2 # 4 # 5 #
SHOW BINLOG EVENTS IN 'master-bin.000003' LIMIT 1,1;
FLUSH LOGS;
--replace_column 2 # 4 # 5 #
SHOW BINLOG EVENTS IN 'master-bin.000004' LIMIT 1,1;

--write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
wait
EOF
--shutdown_server 30
--source include/wait_until_disconnected.inc

--append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
restart
EOF

--connection default
--enable_reconnect
--source include/wait_until_connected_again.inc
--connection server_1
--enable_reconnect
--source include/wait_until_connected_again.inc

--replace_column 2 # 4 # 5 #
SHOW BINLOG EVENTS IN 'master-bin.000005' LIMIT 1,1;
--source include/show_binary_logs.inc

INSERT INTO t1 VALUES(5);

--connection server_2
--let $wait_condition= SELECT COUNT(*) = 5 FROM t1
--source include/wait_condition.inc
SELECT * FROM t1 ORDER BY a;

--echo *** Test that @@gtid_slave_pos and @@gtid_current_pos are correctly loaded even if slave threads have not started. ***
--let $slave_pos1= `SELECT @@GLOBAL.gtid_slave_pos`
--let $current_pos1= `SELECT @@GLOBAL.gtid_current_pos`

--write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
wait
EOF
--shutdown_server 30
--source include/wait_until_disconnected.inc

--append_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
restart: --skip-slave-start=1 --skip-log-bin
EOF
--enable_reconnect
--source include/wait_until_connected_again.inc
--disable_query_log
eval SET @slave_pos1= "$slave_pos1";
eval SET @current_pos1= "$current_pos1";
--enable_query_log
SET @slave_pos2= @@GLOBAL.gtid_slave_pos;
SET @current_pos2= @@GLOBAL.gtid_current_pos;
SELECT IF(@slave_pos1=@slave_pos2, "OK", CONCAT(@slave_pos1, " != ", @slave_pos2));
SELECT IF(@current_pos1=@current_pos2, "OK", CONCAT(@current_pos1, " != ", @current_pos2));
--source include/start_slave.inc


--connection server_1
DROP TABLE t1;

--source include/rpl_end.inc