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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
|
--source include/master-slave.inc
--echo #
--echo # New --dump-slave, --apply-slave-statements functionality
--echo #
# There is a gap between when START SLAVE returns and when MASTER_LOG_FILE and
# MASTER_LOG_POS are set. Ensure that we don't call SHOW SLAVE STATUS during
# that gap.
--sync_slave_with_master
connection master;
use test;
connection slave;
# Execute mysqldump with --dump-slave
--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
--exec $MYSQL_DUMP_SLAVE --compact --dump-slave test
# Execute mysqldump with --dump-slave and --apply-slave-statements
--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
--exec $MYSQL_DUMP_SLAVE --compact --dump-slave --apply-slave-statements test
--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
--replace_result $MASTER_MYPORT MASTER_MYPORT
# Execute mysqldump with --dump-slave ,--apply-slave-statements and --include-master-host-port
--exec $MYSQL_DUMP_SLAVE --compact --dump-slave --apply-slave-statements --include-master-host-port test
#
# MDEV-5624 mysqldump --dump-slave option does not restart the replication if the dump has failed
#
start slave;
--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
--error 2
--exec $MYSQL_DUMP_SLAVE --compact --dump-slave no_such_db
start slave;
--echo *** Test mysqldump --dump-slave GTID/non-gtid functionality.
--connection master
SET gtid_seq_no = 1000;
CREATE TABLE t1 (a INT PRIMARY KEY);
DROP TABLE t1;
--sync_slave_with_master
--connection slave
# Inject a local transaction on the slave to check that this is not considered
# for --dump-slave.
CREATE TABLE t2 (a INT PRIMARY KEY);
DROP TABLE t2;
--echo
--echo 1. --dump-slave=1 --gtid
--echo
--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
--exec $MYSQL_DUMP_SLAVE --compact --dump-slave=1 --gtid test
--echo
--echo 1a. --dump-slave=1
--echo
--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
--exec $MYSQL_DUMP_SLAVE --compact --dump-slave=1 test
--echo
--echo 2. --dump-slave=2 --gtid
--echo
--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
--exec $MYSQL_DUMP_SLAVE --compact --dump-slave=2 --gtid test
--echo
--echo 2. --dump-slave=2
--echo
--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
--exec $MYSQL_DUMP_SLAVE --compact --dump-slave=2 test
--echo *** Test mysqldump --master-data GTID/non-gtid functionality.
--echo
--echo 1. --master-data=1 --gtid
--echo
--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
--exec $MYSQL_DUMP_SLAVE --compact --master-data=1 --gtid test
--echo
--echo 1a. --master-data=1
--echo
--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
--exec $MYSQL_DUMP_SLAVE --compact --master-data=1 test
--echo
--echo 2. --master-data=2 --gtid
--echo
--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
--exec $MYSQL_DUMP_SLAVE --compact --master-data=2 --gtid test
--echo
--echo 2a. --master-data=2
--echo
--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
--exec $MYSQL_DUMP_SLAVE --compact --master-data=2 test
--echo
--echo 3. --master-data --single-transaction --gtid
--echo
--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
--exec $MYSQL_DUMP_SLAVE --compact --master-data --single-transaction --gtid test
--echo
--echo 3a. --master-data --single-transaction
--echo
--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
--exec $MYSQL_DUMP_SLAVE --compact --master-data --single-transaction test
--echo
--echo 4. --master-data=2 --dump-slave=2 --single-transaction --gtid (MDEV-4827)
--echo
--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/ /MariaDB dump.*/MariaDB dump/ /Dump completed.*/Dump completed/ /Server version.*/Server version/
--exec $MYSQL_DUMP_SLAVE --master-data=2 --dump-slave=2 --single-transaction --gtid test
--echo
--echo
--echo 4a. --master-data=2 --dump-slave=2 --single-transaction (MDEV-4827)
--echo
--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/ /MariaDB dump.*/MariaDB dump/ /Dump completed.*/Dump completed/ /Server version.*/Server version/
--exec $MYSQL_DUMP_SLAVE --master-data=2 --dump-slave=2 --single-transaction test
--echo
#
# MDEV-32611 Added test for mysqldump --delete-master-logs option.
# This options is alias of
# get binlogs: show master status -> flush logs -> purge binary logs to <new_binlog>
# sequence and this test is derived using the same pattern.
#
connection master;
CREATE TABLE t (
id int
);
insert into t values (1);
insert into t values (2);
drop table t;
--sync_slave_with_master
# MDEV-32953: Because --delete-master-logs immediately purges logs after
# flushing, it is possible the binlog dump threads will still be using the old
# log when the purge executes, disallowing the file from being deleted.
# Therefore, we temporarily stop the slave so there is no chance the old binlog
# is still being referenced. master_use_gtid=Slave_pos is necessary to still
# appear up-to-date to the master on restart after the master has flushed the
# logs (while the slave is offline). Otherwise (i.e. if using binlog file/pos),
# the slave would point to a purged log file, and receive an error immediately
# upon connecting to the master.
--source include/stop_slave.inc
change master to master_use_gtid=slave_pos;
connection master;
--echo # Ensuring the binlog dump thread is killed on primary...
--disable_query_log
--let $binlog_dump_thd_tid= `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE COMMAND LIKE 'Binlog Dump'`
if ($binlog_dump_thd_tid)
{
--eval kill $binlog_dump_thd_tid
}
--let $wait_condition= SELECT COUNT(*)=0 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE COMMAND LIKE 'Binlog Dump'
--source include/wait_condition.inc
--enable_query_log
--let $predump_binlog_filename= query_get_value(SHOW MASTER STATUS, File, 1)
# Execute mysqldump with delete-master-logs option
--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
--exec $MYSQL_DUMP --compact --no-create-info --no-data --delete-master-logs test
--let $postdump_binlog_filename= query_get_value(SHOW MASTER STATUS, File, 1)
--let $postdump_first_binary_log_filename= query_get_value(SHOW BINARY LOGS, Log_name, 1)
if ($predump_binlog_filename == $postdump_binlog_filename)
{
--echo # predump_binlog_filename: $predump_binlog_filename
--echo # postdump_binlog_filename: $postdump_binlog_filename
--die Master state didn't change after mariadb-dump with --delete-master-logs.
}
if ($postdump_first_binary_log_filename != $postdump_binlog_filename)
{
--echo # postdump_first_binary_log_filename: $postdump_first_binary_log_filename
--echo # postdump_binlog_filename: $postdump_binlog_filename
--die Master binlog wasn't deleted after mariadb-dump with --delete-master-logs.
}
connection slave;
--source include/start_slave.inc
# MDEV-33212: mysqldump uses MASTER_LOG_POS with dump-slave
# The bug was that the MASTER_LOG_POS was wrong. So check that it is correct.
--connection master
--let $pos= query_get_value(SHOW MASTER STATUS, Position, 1)
--sync_slave_with_master
--connection master
--exec $MYSQL_DUMP_SLAVE --compact --dump-slave test >$MYSQLTEST_VARDIR/tmp/MDEV-33212.sql
--let SEARCH_RANGE=500000000
--let SEARCH_FILE=$MYSQLTEST_VARDIR/tmp/MDEV-33212.sql
--let SEARCH_PATTERN= MASTER_LOG_POS=$pos
--let SEARCH_OUTPUT=count
--source include/search_pattern_in_file.inc
--remove_file $MYSQLTEST_VARDIR/tmp/MDEV-33212.sql
--source include/rpl_end.inc
|