MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
rpl_mts_crash_safe.inc
1 # ==== Purpose ====
2 #
3 # This file is an engine to process commands like
4 # rpl_mixing_engines.inc. It has the same set of commands, and in
5 # addition the extra command 'recovery'. The 'configure' and 'clean'
6 # commands are also extended version of the same commands in
7 # rpl_mixing_engines.inc.
8 #
9 # ==== Usage ====
10 #
11 # See rpl_mixing_engines.inc.
12 #
13 # ==== Implementation ====
14 #
15 # This file has its own code for 'configure' and 'clean'. Other
16 # commands are delegated to rpl_mixing_engines.inc.
17 
18 --let $rmcs_initial_commands= $commands
19 
20 #
21 # Creates tables used throughout the test and changes the type of the
22 # mysql.slave_relay_log_info to Innodb.
23 #
24 if ($commands == configure)
25 {
26  --echo ==== begin rpl_mts_crash_safe.inc:configure ====
27  --let $count_database=1
28  while ($count_database <= $max_workers)
29  {
30  --echo ---- begin configure database test_$count_database ----
31  --connection master
32  --let $commands= configure
33  --let $database_name=test_$count_database
34  --source extra/rpl_tests/rpl_mixing_engines.inc
35  --echo ---- end configure database test_$count_database ----
36  inc $count_database;
37  }
38 
39  --sync_slave_with_master
40  --source include/stop_slave.inc
41  let $saved_workers= `SELECT @@global.slave_parallel_workers`;
42  let $saved_checkpoint= `SELECT @@global.slave_checkpoint_period`;
43 
44  SHOW CREATE TABLE mysql.slave_master_info;
45  SHOW CREATE TABLE mysql.slave_relay_log_info;
46  SHOW CREATE TABLE mysql.slave_worker_info;
47  ALTER TABLE mysql.slave_master_info ENGINE= Innodb;
48  ALTER TABLE mysql.slave_relay_log_info ENGINE= Innodb;
49  ALTER TABLE mysql.slave_worker_info ENGINE= Innodb;
50  SHOW CREATE TABLE mysql.slave_master_info;
51  SHOW CREATE TABLE mysql.slave_relay_log_info;
52  SHOW CREATE TABLE mysql.slave_worker_info;
53  --let $commands=
54  --echo ==== end rpl_mts_crash_safe.inc:configure ====
55 }
56 
57 if ($commands == clean)
58 {
59  --echo ==== begin rpl_mts_crash_safe.inc:clean ====
60  --connection slave
61  --source include/stop_slave.inc
62  --disable_query_log
63  eval SET @@global.slave_parallel_workers= $saved_workers;
64  eval SET @@global.slave_checkpoint_period= $saved_checkpoint;
65  --enable_query_log
66  --source include/start_slave.inc
67 
68  --connection master
69  --let $count_database=1
70  while ($count_database <= $max_workers)
71  {
72  --echo ---- begin clean database test_$count_database ----
73  --let $commands= clean
74  --let $database_name=test_$count_database
75  --source extra/rpl_tests/rpl_mixing_engines.inc
76  --echo ---- end clean database test_$count_database ----
77  inc $count_database;
78  }
79  --let $commands=
80  --echo ==== end rpl_mts_crash_safe.inc:clean ====
81 }
82 
83 if ($commands == recovery)
84 {
85  --echo ==== begin rpl_mts_crash_safe.inc:recovery ====
86  --connection master
87  let $m_before_master_file= query_get_value("SHOW MASTER STATUS", "File", 1);
88  let $m_before_master_pos= query_get_value("SHOW MASTER STATUS", "Position", 1);
89 
90  #### Guaranteeing that all events in the binary log are transfered to the slave ######
91  --connection slave
92  let $saved_current_workers= `SELECT @@global.slave_parallel_workers`;
93  let $saved_current_checkpoint= `SELECT @@global.slave_checkpoint_period`;
94  SET GLOBAL debug="d,rotate_slave_debug_group";
95  --source include/start_slave_io.inc
96  let $wait_condition=SELECT Master_log_pos = $m_before_master_pos AND Master_log_name = "$m_before_master_file" FROM mysql.slave_master_info;
97  let $show_rpl_debug_info= 1;
98  --source include/wait_condition.inc
99 
100  #### Crashing server after assigning and processing jobs ######
101  --connection slave
102 
103  --let $mts_run=`select @@global.slave_parallel_workers > 0`
104  eval SET @@global.slave_checkpoint_group= $count_debug_groups;
105  SET GLOBAL debug="d,check_slave_debug_group";
106  SET GLOBAL debug="+d,mts_distribute_round_robin";
107  --exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
108  --error 0, 2013
109  START SLAVE SQL_THREAD;
110  --source include/wait_until_disconnected.inc
111 
112  #### MTS can not relay-log-recover in presense of gaps that the test creates
113  #### The server has to be restarted with --relay-log-recovery = 0 followed by
114  #### START SLAVE UNTIL SQL_AFTER_MTS_GAPS.
115 
116  if ($mts_run)
117  {
118  --echo ** fixing gaps **
119  --let $rpl_server_number= 2
120  --let $rpl_server_parameters= --skip-slave-start --relay-log-recovery=0 --slave-parallel-workers=0
121 
122  --let $rpl_debug= 1
123  --source include/rpl_start_server.inc
124  --let $rpl_debug= 0
125 
126  START SLAVE UNTIL SQL_AFTER_MTS_GAPS;
127  --let $slave_param= Until_Condition
128  --let $slave_param_value= DONE
129  --source include/wait_for_slave_param.inc
130  # there's a chance it will hang at this point (thanks to pre-exec UNTIL check)
131  --source include/wait_for_slave_sql_to_stop.inc
132  }
133 
134  --echo ** regular restart **
135  --let $rpl_server_number= 2
136  --let $rpl_server_parameters= --skip-slave-start --slave-transaction-retries=0 --relay-log-info-repository=TABLE --master-info-repository=TABLE --sync-master-info=1
137  --let $rpl_debug= 1
138  --source include/rpl_restart_server.inc
139  --let $rpl_debug= 0
140 
141  #### Checking if the recovery worked and the coordinator has an updated state. ####
142  --connection slave
143  --source include/start_slave_io.inc
144  let $wait_condition=SELECT Master_log_pos = $m_before_master_pos AND Master_log_name = "$m_before_master_file" FROM mysql.slave_master_info;
145  --source include/wait_condition.inc
146  --enable_query_log
147 
148  --source include/start_slave_sql.inc
149  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;
150  --source include/wait_condition.inc
151 
152  --source include/stop_slave.inc
153  eval SET @@global.slave_parallel_workers= $saved_current_workers;
154  eval SET @@global.slave_checkpoint_period= $saved_current_checkpoint;
155 
156  --let $commands=
157  --echo ==== end rpl_mts_crash_safe.inc:recovery ====
158 }
159 
160 if ($commands != '')
161 {
162  --echo ==== begin rpl_mts_crash_safe.inc:rpl_mixing_engines.inc ====
163  --connection master
164  --source extra/rpl_tests/rpl_mixing_engines.inc
165  --echo ==== end rpl_mts_crash_safe.inc:rpl_mixing_engines.inc ====
166 }
167 
168 --let $commands= $rmcs_initial_commands