|
| 1 | +# |
| 2 | +# This include file is used by more than one test suite |
| 3 | +# (currently binlog and binlog_encryption). |
| 4 | +# Please check all dependent tests after modifying it |
| 5 | +# |
| 6 | + |
| 7 | +# |
| 8 | +# testing of purging of binary log files bug#18199/Bug#18453 |
| 9 | +# |
| 10 | +source include/have_log_bin.inc; |
| 11 | +source include/not_embedded.inc; |
| 12 | +# Don't test this under valgrind, memory leaks will occur |
| 13 | +--source include/not_valgrind.inc |
| 14 | +source include/have_debug.inc; |
| 15 | +# Avoid CrashReporter popup on Mac |
| 16 | +--source include/not_crashrep.inc |
| 17 | +call mtr.add_suppression('Attempting backtrace'); |
| 18 | +call mtr.add_suppression('MSYQL_BIN_LOG::purge_logs failed to process registered files that would be purged.'); |
| 19 | +call mtr.add_suppression('MSYQL_BIN_LOG::open failed to sync the index file'); |
| 20 | +call mtr.add_suppression('Turning logging off for the whole duration of the MySQL server process.'); |
| 21 | +call mtr.add_suppression('Could not open .*'); |
| 22 | +call mtr.add_suppression('MSYQL_BIN_LOG::purge_logs failed to clean registers before purging logs.'); |
| 23 | +flush tables; |
| 24 | + |
| 25 | +let $old=`select @@debug`; |
| 26 | + |
| 27 | +RESET MASTER; |
| 28 | + |
| 29 | +let $MYSQLD_DATADIR= `select @@datadir`; |
| 30 | +let $INDEX=$MYSQLD_DATADIR/master-bin.index; |
| 31 | + |
| 32 | +# |
| 33 | +# testing purge binary logs TO |
| 34 | +# |
| 35 | + |
| 36 | +flush logs; |
| 37 | +flush logs; |
| 38 | +flush logs; |
| 39 | + |
| 40 | +source include/show_binary_logs.inc; |
| 41 | +remove_file $MYSQLD_DATADIR/master-bin.000001; |
| 42 | +flush tables; |
| 43 | + |
| 44 | +# there must be a warning with file names |
| 45 | +replace_regex /\.[\\\/]master/master/; |
| 46 | +--source include/wait_for_binlog_checkpoint.inc |
| 47 | +purge binary logs TO 'master-bin.000004'; |
| 48 | + |
| 49 | +--echo *** must show a list starting from the 'TO' argument of PURGE *** |
| 50 | +source include/show_binary_logs.inc; |
| 51 | + |
| 52 | +# |
| 53 | +# testing purge binary logs BEFORE |
| 54 | +# |
| 55 | + |
| 56 | +reset master; |
| 57 | + |
| 58 | +flush logs; |
| 59 | +flush logs; |
| 60 | +flush logs; |
| 61 | +remove_file $MYSQLD_DATADIR/master-bin.000001; |
| 62 | + |
| 63 | +--echo *** must be a warning master-bin.000001 was not found *** |
| 64 | +let $date=`select NOW() + INTERVAL 1 MINUTE`; |
| 65 | +--disable_query_log |
| 66 | +replace_regex /\.[\\\/]master/master/; |
| 67 | +--source include/wait_for_binlog_checkpoint.inc |
| 68 | +eval purge binary logs BEFORE '$date'; |
| 69 | +--enable_query_log |
| 70 | + |
| 71 | +--echo *** must show one record, of the active binlog, left in the index file after PURGE *** |
| 72 | +source include/show_binary_logs.inc; |
| 73 | + |
| 74 | +# |
| 75 | +# testing a fatal error |
| 76 | +# Turning a binlog file into a directory must be a portable setup |
| 77 | +# |
| 78 | + |
| 79 | +reset master; |
| 80 | + |
| 81 | +flush logs; |
| 82 | +flush logs; |
| 83 | +flush logs; |
| 84 | + |
| 85 | +remove_file $MYSQLD_DATADIR/master-bin.000001; |
| 86 | +mkdir $MYSQLD_DATADIR/master-bin.000001; |
| 87 | + |
| 88 | +--source include/wait_for_binlog_checkpoint.inc |
| 89 | +--error ER_BINLOG_PURGE_FATAL_ERR |
| 90 | +purge binary logs TO 'master-bin.000002'; |
| 91 | +replace_regex /\.[\\\/]master/master/; |
| 92 | +show warnings; |
| 93 | +rmdir $MYSQLD_DATADIR/master-bin.000001; |
| 94 | +--disable_warnings |
| 95 | +reset master; |
| 96 | +--enable_warnings |
| 97 | + |
| 98 | +--echo # crash_purge_before_update_index |
| 99 | +flush logs; |
| 100 | + |
| 101 | +--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect |
| 102 | +SET SESSION debug_dbug="+d,crash_purge_before_update_index"; |
| 103 | +--source include/wait_for_binlog_checkpoint.inc |
| 104 | +--error 2013 |
| 105 | +purge binary logs TO 'master-bin.000002'; |
| 106 | + |
| 107 | +--enable_reconnect |
| 108 | +--source include/wait_until_connected_again.inc |
| 109 | + |
| 110 | +file_exists $MYSQLD_DATADIR/master-bin.000001; |
| 111 | +file_exists $MYSQLD_DATADIR/master-bin.000002; |
| 112 | +file_exists $MYSQLD_DATADIR/master-bin.000003; |
| 113 | +--chmod 0644 $INDEX |
| 114 | +-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR |
| 115 | +-- eval SET @index=LOAD_FILE('$index') |
| 116 | +-- replace_regex /\.[\\\/]master/master/ |
| 117 | +SELECT @index; |
| 118 | + |
| 119 | +--echo # crash_purge_non_critical_after_update_index |
| 120 | +flush logs; |
| 121 | + |
| 122 | +--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect |
| 123 | +SET SESSION debug_dbug="+d,crash_purge_non_critical_after_update_index"; |
| 124 | +--source include/wait_for_binlog_checkpoint.inc |
| 125 | +--error 2013 |
| 126 | +purge binary logs TO 'master-bin.000004'; |
| 127 | + |
| 128 | +--enable_reconnect |
| 129 | +--source include/wait_until_connected_again.inc |
| 130 | + |
| 131 | +--error 1 |
| 132 | +file_exists $MYSQLD_DATADIR/master-bin.000001; |
| 133 | +--error 1 |
| 134 | +file_exists $MYSQLD_DATADIR/master-bin.000002; |
| 135 | +--error 1 |
| 136 | +file_exists $MYSQLD_DATADIR/master-bin.000003; |
| 137 | +--chmod 0644 $INDEX |
| 138 | +-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR |
| 139 | +-- eval SET @index=LOAD_FILE('$index') |
| 140 | +-- replace_regex /\.[\\\/]master/master/ |
| 141 | +SELECT @index; |
| 142 | + |
| 143 | +--echo # crash_purge_critical_after_update_index |
| 144 | +flush logs; |
| 145 | + |
| 146 | +--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect |
| 147 | +SET SESSION debug_dbug="+d,crash_purge_critical_after_update_index"; |
| 148 | +--source include/wait_for_binlog_checkpoint.inc |
| 149 | +--error 2013 |
| 150 | +purge binary logs TO 'master-bin.000006'; |
| 151 | + |
| 152 | +--enable_reconnect |
| 153 | +--source include/wait_until_connected_again.inc |
| 154 | + |
| 155 | +--error 1 |
| 156 | +file_exists $MYSQLD_DATADIR/master-bin.000004; |
| 157 | +--error 1 |
| 158 | +file_exists $MYSQLD_DATADIR/master-bin.000005; |
| 159 | +file_exists $MYSQLD_DATADIR/master-bin.000006; |
| 160 | +file_exists $MYSQLD_DATADIR/master-bin.000007; |
| 161 | +--error 1 |
| 162 | +file_exists $MYSQLD_DATADIR/master-bin.000008; |
| 163 | +--chmod 0644 $INDEX |
| 164 | +-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR |
| 165 | +-- eval SET @index=LOAD_FILE('$index') |
| 166 | +-- replace_regex /\.[\\\/]master/master/ |
| 167 | +SELECT @index; |
| 168 | + |
| 169 | +--echo # crash_create_non_critical_before_update_index |
| 170 | +--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect |
| 171 | +SET SESSION debug_dbug="+d,crash_create_non_critical_before_update_index"; |
| 172 | +--error 2013 |
| 173 | +flush logs; |
| 174 | + |
| 175 | +--enable_reconnect |
| 176 | +--source include/wait_until_connected_again.inc |
| 177 | + |
| 178 | +file_exists $MYSQLD_DATADIR/master-bin.000008; |
| 179 | +--error 1 |
| 180 | +file_exists $MYSQLD_DATADIR/master-bin.000009; |
| 181 | +--chmod 0644 $INDEX |
| 182 | +-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR |
| 183 | +-- eval SET @index=LOAD_FILE('$index') |
| 184 | +-- replace_regex /\.[\\\/]master/master/ |
| 185 | +SELECT @index; |
| 186 | + |
| 187 | +--echo # crash_create_critical_before_update_index |
| 188 | +--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect |
| 189 | +SET SESSION debug_dbug="+d,crash_create_critical_before_update_index"; |
| 190 | +--error 2013 |
| 191 | +flush logs; |
| 192 | + |
| 193 | +--enable_reconnect |
| 194 | +--source include/wait_until_connected_again.inc |
| 195 | + |
| 196 | +file_exists $MYSQLD_DATADIR/master-bin.000009; |
| 197 | +--error 1 |
| 198 | +file_exists $MYSQLD_DATADIR/master-bin.000010; |
| 199 | +--error 1 |
| 200 | +file_exists $MYSQLD_DATADIR/master-bin.000011; |
| 201 | +--chmod 0644 $INDEX |
| 202 | +-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR |
| 203 | +-- eval SET @index=LOAD_FILE('$index') |
| 204 | +-- replace_regex /\.[\\\/]master/master/ |
| 205 | +SELECT @index; |
| 206 | + |
| 207 | +--echo # crash_create_after_update_index |
| 208 | +--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect |
| 209 | +SET SESSION debug_dbug="+d,crash_create_after_update_index"; |
| 210 | +--error 2013 |
| 211 | +flush logs; |
| 212 | + |
| 213 | +--enable_reconnect |
| 214 | +--source include/wait_until_connected_again.inc |
| 215 | + |
| 216 | +file_exists $MYSQLD_DATADIR/master-bin.000010; |
| 217 | +file_exists $MYSQLD_DATADIR/master-bin.000011; |
| 218 | +--chmod 0644 $INDEX |
| 219 | +-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR |
| 220 | +-- eval SET @index=LOAD_FILE('$index') |
| 221 | +-- replace_regex /\.[\\\/]master/master/ |
| 222 | +SELECT @index; |
| 223 | + |
| 224 | +--echo # |
| 225 | +--echo # This should put the server in unsafe state and stop |
| 226 | +--echo # accepting any command. If we inject a fault at this |
| 227 | +--echo # point and continue the execution the server crashes. |
| 228 | +--echo # |
| 229 | + |
| 230 | +--chmod 0644 $INDEX |
| 231 | +-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR |
| 232 | +-- eval SET @index=LOAD_FILE('$index') |
| 233 | +-- replace_regex /\.[\\\/]master/master/ |
| 234 | +SELECT @index; |
| 235 | + |
| 236 | +--echo # fault_injection_registering_index |
| 237 | +SET SESSION debug_dbug="+d,fault_injection_registering_index"; |
| 238 | +-- replace_regex /\.[\\\/]master/master/ |
| 239 | +-- error ER_CANT_OPEN_FILE |
| 240 | +flush logs; |
| 241 | + |
| 242 | +--chmod 0644 $INDEX |
| 243 | +-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR |
| 244 | +-- eval SET @index=LOAD_FILE('$index') |
| 245 | +-- replace_regex /\.[\\\/]master/master/ |
| 246 | +SELECT @index; |
| 247 | + |
| 248 | +--source include/restart_mysqld.inc |
| 249 | + |
| 250 | +--chmod 0644 $INDEX |
| 251 | +-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR |
| 252 | +-- eval SET @index=LOAD_FILE('$index') |
| 253 | +-- replace_regex /\.[\\\/]master/master/ |
| 254 | +SELECT @index; |
| 255 | + |
| 256 | +--echo # fault_injection_updating_index |
| 257 | +SET SESSION debug_dbug="+d,fault_injection_updating_index"; |
| 258 | +-- replace_regex /\.[\\\/]master/master/ |
| 259 | +-- error ER_CANT_OPEN_FILE |
| 260 | +flush logs; |
| 261 | + |
| 262 | +--chmod 0644 $INDEX |
| 263 | +-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR |
| 264 | +-- eval SET @index=LOAD_FILE('$index') |
| 265 | +-- replace_regex /\.[\\\/]master/master/ |
| 266 | +SELECT @index; |
| 267 | + |
| 268 | +--source include/restart_mysqld.inc |
| 269 | + |
| 270 | +--chmod 0644 $INDEX |
| 271 | +-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR |
| 272 | +-- eval SET @index=LOAD_FILE('$index') |
| 273 | +-- replace_regex /\.[\\\/]master/master/ |
| 274 | +SELECT @index; |
| 275 | + |
| 276 | +eval SET SESSION debug_dbug="$old"; |
| 277 | + |
| 278 | +--echo End of tests |
0 commit comments