-
Notifications
You must be signed in to change notification settings - Fork 4k
/
Copy pathmta_crash_safe.inc
164 lines (144 loc) · 5.93 KB
/
mta_crash_safe.inc
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
# ==== Purpose ====
#
# This file is an engine to process commands like
# common/rpl/mixing_engines.inc. It has the same set of commands, and in
# addition the extra command 'recovery'. The 'configure' and 'clean'
# commands are also extended version of the same commands in
# common/rpl/mixing_engines.inc.
#
# ==== Usage ====
#
# See common/rpl/mixing_engines.inc.
#
# ==== Implementation ====
#
# This file has its own code for 'configure' and 'clean'. Other
# commands are delegated to common/rpl/mixing_engines.inc.
--let $rmcs_initial_commands= $commands
#
# Creates tables used throughout the test and changes the type of the
# mysql.slave_relay_log_info to Innodb.
#
if ($commands == configure)
{
--echo ==== begin rpl_mta_crash_safe.inc:configure ====
--let $count_database= 1
while ($count_database <= $max_workers)
{
--echo ---- begin configure database test_$count_database ----
--connection master
--let $commands= configure
--let $database_name= test_$count_database
--source common/rpl/mixing_engines.inc
--echo ---- end configure database test_$count_database ----
inc $count_database;
}
--sync_slave_with_master
--source include/rpl/stop_replica.inc
let $saved_checkpoint= `SELECT @@global.replica_checkpoint_period`;
SHOW CREATE TABLE mysql.slave_master_info;
SHOW CREATE TABLE mysql.slave_relay_log_info;
SHOW CREATE TABLE mysql.slave_worker_info;
ALTER TABLE mysql.slave_master_info ENGINE= Innodb;
ALTER TABLE mysql.slave_relay_log_info ENGINE= Innodb;
ALTER TABLE mysql.slave_worker_info ENGINE= Innodb;
SHOW CREATE TABLE mysql.slave_master_info;
SHOW CREATE TABLE mysql.slave_relay_log_info;
SHOW CREATE TABLE mysql.slave_worker_info;
--let $commands=
--echo ==== end rpl_mta_crash_safe.inc:configure ====
}
if ($commands == clean)
{
--echo ==== begin rpl_mta_crash_safe.inc:clean ====
--connection slave
--source include/rpl/stop_replica.inc
--disable_query_log
eval SET @@global.replica_checkpoint_period= $saved_checkpoint;
--enable_query_log
--source include/rpl/start_replica.inc
--connection master
--let $count_database= 1
while ($count_database <= $max_workers)
{
--echo ---- begin clean database test_$count_database ----
--let $commands= clean
--let $database_name= test_$count_database
--source common/rpl/mixing_engines.inc
--echo ---- end clean database test_$count_database ----
inc $count_database;
}
--let $commands=
--echo ==== end rpl_mta_crash_safe.inc:clean ====
}
if ($commands == recovery)
{
--echo ==== begin rpl_mta_crash_safe.inc:recovery ====
--connection master
let $m_before_master_file= query_get_value("SHOW BINARY LOG STATUS", "File", 1);
let $m_before_master_pos= query_get_value("SHOW BINARY LOG STATUS", "Position", 1);
#### Guaranteeing that all events in the binary log are transfered to the slave ######
--connection slave
let $saved_current_workers= `SELECT @@global.replica_parallel_workers`;
let $saved_current_checkpoint= `SELECT @@global.replica_checkpoint_period`;
SET GLOBAL debug="d,rotate_replica_debug_group";
--source include/rpl/start_receiver.inc
let $wait_condition=SELECT Master_log_pos = $m_before_master_pos AND Master_log_name = "$m_before_master_file" FROM mysql.slave_master_info;
let $show_rpl_debug_info= 1;
--source include/wait_condition_or_abort.inc
#### Crashing server after assigning and processing jobs ######
--connection slave
--let $mts_run=`select @@global.replica_parallel_workers > 0`
eval SET @@global.replica_checkpoint_group= $count_debug_groups;
SET GLOBAL debug="d,check_replica_debug_group";
SET GLOBAL debug="+d,mta_distribute_round_robin";
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
--error 0, 2013
START REPLICA SQL_THREAD;
--source include/wait_until_disconnected.inc
#### MTS can not relay-log-recover in presense of gaps that the test creates
#### The server has to be restarted with --relay-log-recovery = 0 followed by
#### START REPLICA UNTIL SQL_AFTER_MTS_GAPS.
if ($mts_run)
{
--echo ** fixing gaps **
--let $rpl_server_number= 2
--let $rpl_server_parameters= --skip-replica-start --relay-log-recovery=0
--source include/rpl/start_server.inc
# Disable warnings as with GTIDS the clause SQL_AFTER_MTS_GAPS has no effect
--disable_warnings
START REPLICA UNTIL SQL_AFTER_MTS_GAPS;
--enable_warnings
--let $slave_param= Until_Condition
--let $slave_param_value= DONE
--source include/rpl/wait_for_replica_status.inc
# there's a chance it will hang at this point (thanks to pre-exec UNTIL check)
--source include/rpl/wait_for_applier_to_stop.inc
}
--echo ** regular restart **
--let $rpl_server_number= 2
--let $rpl_server_parameters= --skip-replica-start --replica-transaction-retries=0 --sync-source-info=1
--source include/rpl/restart_server.inc
#### Checking if the recovery worked and the coordinator has an updated state. ####
--connection slave
--source include/rpl/start_receiver.inc
let $wait_condition=SELECT Master_log_pos = $m_before_master_pos AND Master_log_name = "$m_before_master_file" FROM mysql.slave_master_info;
--source include/wait_condition_or_abort.inc
--enable_query_log
--source include/rpl/start_applier.inc
let $wait_condition=SELECT Master_log_pos = $m_before_master_pos AND Master_log_name = "$m_before_master_file" FROM mysql.slave_relay_log_info;
--source include/wait_condition_or_abort.inc
--source include/rpl/stop_replica.inc
eval SET @@global.replica_parallel_workers= $saved_current_workers;
eval SET @@global.replica_checkpoint_period= $saved_current_checkpoint;
--let $commands=
--echo ==== end rpl_mta_crash_safe.inc:recovery ====
}
if ($commands != '')
{
--echo ==== begin rpl_mta_crash_safe.inc:common/rpl/mixing_engines.inc ====
--connection master
--source common/rpl/mixing_engines.inc
--echo ==== end rpl_mta_crash_safe.inc:common/rpl/mixing_engines.inc ====
}
--let $commands= $rmcs_initial_commands