| 1 |
# ==== Purpose ==== |
| 2 |
# Like rpl_atomic_ddl.test this test file |
| 3 |
# proves successful slave service recovery after a simulated failure |
| 4 |
# at handling recoverable DDL queries. |
| 5 |
# The "half" atomic cases include those DDL statements that can not |
| 6 |
# roll back. Once this feature is implemented for a statement it can |
| 7 |
# merged with the fully atomic ones of rpl_atomic_ddl.test. |
| 8 |
# See rpl_atomic_ddl.test for more info. |
| 9 |
# |
| 10 |
# ==== Implementation ==== |
| 11 |
# |
| 12 |
# Mostly follows rpl_atomic_ddl.test. |
| 13 |
# Difference is in that the slave does not try to simulate |
| 14 |
# a failure before binary logging stage has been completed. That is |
| 15 |
# only SET @@GLOBAL.debug="+d,crash_commit_after_log" and |
| 16 |
# pre_binlog_check, see below commented, is not used. |
| 17 |
# |
| 18 |
# ==== References ==== |
| 19 |
# WL#9175 Correct recovery of DDL statements/transactions by binary log |
| 20 |
# |
| 21 |
# |
| 22 |
# Params: |
| 23 |
# --let $rpl_atomic_ddl_print_verbose # get out more info |
| 24 |
# |
| 25 |
# === Limitations === |
| 26 |
# --force-restart is required to run the test. |
| 27 |
# |
| 28 |
# When the object deletion was interrupted by crash |
| 29 |
# there could be errors on object recreation attempt like |
| 30 |
# 1007: Can't create database '...'; database exists |
| 31 |
# due to |
| 32 |
# Bug #25663287 DROP DATABASE DOESN'T GETS RECOVERED CORRECTLY UPON POST BINLOG CRASH/RESTART |
| 33 |
# or asserts like in |
| 34 |
# Bug #25651042 TANSACTION DOES NOT POST-CRASH RECOVER IN INNODB EVEN IF PREPARED AND BINLOGGED |
| 35 |
# |
| 36 |
|
| 37 |
--let $rpl_atomic_ddl_print_verbose=1 |
| 38 |
|
| 39 |
--source include/not_crashrep.inc |
| 40 |
--source include/not_valgrind.inc |
| 41 |
--source include/have_log_bin.inc |
| 42 |
--source include/have_debug.inc |
| 43 |
--source include/have_binlog_format_mixed.inc |
| 44 |
--let $rpl_gtid_utils= 1 |
| 45 |
--source include/master-slave.inc |
| 46 |
|
| 47 |
--source include/rpl_connection_slave.inc |
| 48 |
call mtr.add_suppression("The replica coordinator and worker threads are stopped"); |
| 49 |
call mtr.add_suppression("Replica worker thread has failed to apply an event"); |
| 50 |
call mtr.add_suppression("Error writing relay log configuration"); |
| 51 |
call mtr.add_suppression("Table 't_2' already exists"); |
| 52 |
call mtr.add_suppression("Operating system error number .* in a file operation"); |
| 53 |
call mtr.add_suppression("Cannot open datafile for read-onl"); |
| 54 |
call mtr.add_suppression("The error means the system cannot"); |
| 55 |
--disable_query_log |
| 56 |
call mtr.add_suppression("You need to use --log-bin to make.* work"); |
| 57 |
call mtr.add_suppression("Could not find a valid tablespace file for"); |
| 58 |
--enable_query_log |
| 59 |
|
| 60 |
--source include/rpl_connection_master.inc |
| 61 |
|
| 62 |
# instructing gtid_step_assert that is called by a sourced file |
| 63 |
# to satisfy to gtid-mode OFF as well. |
| 64 |
--let $gtid_mode_on= `SELECT @@GLOBAL.GTID_MODE = 'ON'` |
| 65 |
--let $gtid_mode= `SELECT @@GLOBAL.GTID_MODE` |
| 66 |
--let $gtid_step_gtid_mode_agnostic=`SELECT '$gtid_mode' != 'ON'` |
| 67 |
|
| 68 |
if (!$crash_commit) |
| 69 |
{ |
| 70 |
--let $commit_message=Crash right after the query has been binary-logged before committed in the engine |
| 71 |
--let $crash_commit="+d,crash_commit_after_log" |
| 72 |
} |
| 73 |
|
| 74 |
|
| 75 |
# Master load |
| 76 |
# |
| 77 |
# Start off with the master side logger table (see the master opt |
| 78 |
# file) that record DDL queries that will be subject to crash |
| 79 |
# simulation on the slave side. The table will hold prescribed |
| 80 |
# post-recovery checks to be performed on the slave side. |
| 81 |
# |
| 82 |
--let $master_log_table=t_checks |
| 83 |
--let $master_log_db=master_db |
| 84 |
--eval CREATE DATABASE $master_log_db |
| 85 |
|
| 86 |
--let $save_curr_db=`SELECT database()` |
| 87 |
--eval USE $master_log_db |
| 88 |
--eval CREATE TABLE IF NOT EXISTS $master_log_table (id INT AUTO_INCREMENT NOT NULL PRIMARY KEY, ddl_query TEXT, pre_binlog_check TEXT, post_binlog_check TEXT); |
| 89 |
|
| 90 |
--eval USE $save_curr_db |
| 91 |
|
| 92 |
--source include/sync_slave_sql_with_master.inc |
| 93 |
--source include/stop_slave_sql.inc |
| 94 |
|
| 95 |
--source include/rpl_connection_master.inc |
| 96 |
|
| 97 |
# |
| 98 |
# The test |
| 99 |
# |
| 100 |
|
| 101 |
# I. Load generation on master: |
| 102 |
|
| 103 |
--let $do_post_prepare=0 |
| 104 |
--let $do_post_binlog=0 |
| 105 |
--let $do_only_regular_logging=1 |
| 106 |
--let $do_show_binlog_events= 0 |
| 107 |
--let $do_count_queries=1 |
| 108 |
--let $count_ddl_queries=0 |
| 109 |
# table name to use by the sourced file below and on this level |
| 110 |
--let $table=t_2 |
| 111 |
--source extra/binlog_tests/binlog_ddl_half_atomic.inc |
| 112 |
|
| 113 |
--source include/rpl_connection_slave.inc |
| 114 |
--source include/start_slave_io.inc |
| 115 |
|
| 116 |
--source include/rpl_connection_master.inc |
| 117 |
--source include/sync_slave_io_with_master.inc |
| 118 |
|
| 119 |
# The receiver thread must be stopped now which |
| 120 |
# crash-safely memorizes the last received event coordinates. |
| 121 |
--source include/rpl_connection_slave.inc |
| 122 |
--source include/stop_slave_io.inc |
| 123 |
|
| 124 |
# II. Event execution on slave interrupted by errors |
| 125 |
|
| 126 |
#--source include/rpl_connection_slave.inc |
| 127 |
# First, a regular error |
| 128 |
--eval CREATE TABLE $table (a int) |
| 129 |
START SLAVE SQL_THREAD; |
| 130 |
--let $slave_sql_errno=convert_error(ER_TABLE_EXISTS_ERROR) |
| 131 |
--source include/wait_for_slave_sql_error.inc |
| 132 |
--eval DROP TABLE $table |
| 133 |
|
| 134 |
# The rest is crash-restart in loop of number of DDL queries |
| 135 |
# in the master load. |
| 136 |
--let $loops=$count_ddl_queries |
| 137 |
--let $id=0 |
| 138 |
while ($loops) |
| 139 |
{ |
| 140 |
--inc $id |
| 141 |
|
| 142 |
# Find the loop's query and it post-recovery checks upon the first recovery |
| 143 |
--source include/rpl_connection_master.inc |
| 144 |
|
| 145 |
--let $current_query=`SELECT ddl_query FROM $master_log_db.$master_log_table WHERE id = $id ` |
| 146 |
#--let $pre_binlog_check=`SELECT pre_binlog_check FROM $master_log_db.$master_log_table WHERE id = $id` |
| 147 |
--let $post_binlog_check=`SELECT post_binlog_check FROM $master_log_db.$master_log_table WHERE id = $id` |
| 148 |
if ($rpl_atomic_ddl_print_verbose) |
| 149 |
{ |
| 150 |
--echo Loop: $id out of $count_ddl_queries; current query: '$current_query'; pre-binlog check: '$pre_binlog_check'; pre-commit check: '$post_binlog_check'; |
| 151 |
} |
| 152 |
|
| 153 |
--source include/rpl_connection_slave.inc |
| 154 |
# |
| 155 |
# Commit recovery upon the pre-commit crash. |
| 156 |
# |
| 157 |
--source include/expect_crash.inc |
| 158 |
--echo *** Query: '$current_query'. $commit_message. *** |
| 159 |
--eval SET @@GLOBAL.debug=$crash_commit |
| 160 |
--source include/gtid_step_reset.inc |
| 161 |
--error 0,2013 |
| 162 |
START SLAVE SQL_THREAD; |
| 163 |
|
| 164 |
# Server wait for stop and restart |
| 165 |
--enable_reconnect |
| 166 |
--source include/wait_until_disconnected.inc |
| 167 |
--let $rpl_server_number= 2 |
| 168 |
--source include/rpl_start_server.inc |
| 169 |
--disable_reconnect |
| 170 |
|
| 171 |
--source include/rpl_connection_slave.inc |
| 172 |
# Proof of the commit recovery is one committed gtid |
| 173 |
--let $gtid_step_only_count=1 |
| 174 |
--let $gtid_step_count=1 |
| 175 |
--source include/gtid_step_assert.inc |
| 176 |
|
| 177 |
# Proof by the master side post-recovery checks |
| 178 |
if ($post_binlog_check) |
| 179 |
{ |
| 180 |
if (!`$post_binlog_check`) |
| 181 |
{ |
| 182 |
--echo *** State check upon recovery after the pre-commit crash fails *** |
| 183 |
--die |
| 184 |
} |
| 185 |
} |
| 186 |
|
| 187 |
--dec $loops |
| 188 |
} # end of while |
| 189 |
|
| 190 |
# Eventually: |
| 191 |
|
| 192 |
--source include/rpl_connection_slave.inc |
| 193 |
--source include/start_slave.inc |
| 194 |
|
| 195 |
--source include/rpl_connection_master.inc |
| 196 |
--eval DROP DATABASE $master_log_db |
| 197 |
|
| 198 |
--source include/sync_slave_sql_with_master.inc |
| 199 |
|
| 200 |
|
| 201 |
--source include/rpl_end.inc |
| 202 |
|
| 203 |
|