You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

278 lines
7.9 KiB

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