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.

150 lines
4.5 KiB

  1. # Proving that stopping in the middle of applying a group of events
  2. # does not have immediate effect if a non-transaction table has been changed.
  3. # The slave sql thread has to try to finish applying first.
  4. # The tests rely on simulation of the killed status.
  5. # The matter of testing correlates to some of `rpl_start_stop_slave' that does
  6. # not require `have_debug'.
  7. connection master;
  8. call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
  9. create table tm (a int auto_increment primary key) engine=myisam;
  10. create table ti (a int auto_increment primary key) engine=innodb;
  11. sync_slave_with_master;
  12. set @@global.debug="+d,stop_slave_middle_group";
  13. connection master;
  14. begin;
  15. insert into ti set a=null;
  16. insert into tm set a=null; # to simulate killed status on the slave
  17. commit;
  18. connection slave;
  19. call mtr.add_suppression("Slave SQL.*Request to stop slave SQL Thread received while applying a group that has non-transactional changes; waiting for completion of the group");
  20. call mtr.add_suppression("Slave SQL.*Slave SQL Thread stopped with incomplete event group having non-transactional changes");
  21. # slave will catch the killed status but won't shut down immediately
  22. # only after the whole group has done (commit)
  23. source include/wait_for_slave_sql_to_stop.inc;
  24. # checking: no error and the group is finished
  25. let $error= query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1);
  26. let $read = query_get_value("SHOW SLAVE STATUS", Read_Master_Log_Pos, 1);
  27. let $exec = query_get_value("SHOW SLAVE STATUS", Exec_Master_Log_Pos, 1);
  28. --disable_query_log
  29. eval SELECT $read = $exec into @check;
  30. --enable_query_log
  31. eval SELECT "NO$error" AS Last_SQL_Error, @check as `true`;
  32. select count(*) as one from tm;
  33. select count(*) as one from ti;
  34. set @@global.debug="-d";
  35. #
  36. # bug#45940 issues around rli->last_event_start_time
  37. # Testing of slave stopped after it had waited (in vain) for
  38. # the group be finished.
  39. # It could not be finished because of simulation of failure to
  40. # receive the terminal part
  41. # The test relay on simulation of the incomplete group in the relay log
  42. # Two cases are verified: a mixed transacton and a mixed multi-table update.
  43. #
  44. # The mixed transacton.
  45. #
  46. source include/start_slave.inc;
  47. connection master;
  48. truncate table tm; # cleanup of former tests
  49. truncate table ti;
  50. #connection slave;
  51. sync_slave_with_master;
  52. set @@global.debug="+d,stop_slave_middle_group";
  53. set @@global.debug="+d,incomplete_group_in_relay_log";
  54. connection master;
  55. begin;
  56. insert into ti set a=null;
  57. insert into tm set a=null;
  58. commit;
  59. connection slave;
  60. # slave will catch the killed status, won't shut down immediately
  61. # but does it eventually having the whole group unfinished (not committed)
  62. source include/wait_for_slave_sql_to_stop.inc;
  63. # checking: the error and group unfinished
  64. let $error= query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1);
  65. let $read = query_get_value("SHOW SLAVE STATUS", Read_Master_Log_Pos, 1);
  66. let $exec = query_get_value("SHOW SLAVE STATUS", Exec_Master_Log_Pos, 1);
  67. --disable_query_log
  68. eval SELECT $read - $exec > 0 into @check;
  69. --enable_query_log
  70. eval SELECT "$error" AS Last_SQL_Error, @check as `true`;
  71. select count(*) as one from tm;
  72. select count(*) as zero from ti;
  73. set @@global.debug="-d";
  74. #
  75. # The mixed multi-table update
  76. #
  77. stop slave;
  78. truncate table tm;
  79. source include/start_slave.inc;
  80. connection master;
  81. #connection slave;
  82. sync_slave_with_master;
  83. set @@global.debug="+d,stop_slave_middle_group";
  84. set @@global.debug="+d,incomplete_group_in_relay_log";
  85. connection master;
  86. update tm as t1, ti as t2 set t1.a=t1.a * 2, t2.a=t2.a * 2;
  87. connection slave;
  88. # slave will catch the killed status, won't shut down immediately
  89. # but does it eventually having the whole group unfinished (not committed)
  90. #
  91. source include/wait_for_slave_sql_to_stop.inc;
  92. # checking: the error and group unfinished
  93. let $error= query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1);
  94. let $read = query_get_value("SHOW SLAVE STATUS", Read_Master_Log_Pos, 1);
  95. let $exec = query_get_value("SHOW SLAVE STATUS", Exec_Master_Log_Pos, 1);
  96. --disable_query_log
  97. eval SELECT $read - $exec > 0 into @check;
  98. --enable_query_log
  99. eval SELECT "$error" AS Last_SQL_Error, @check as `true`;
  100. select max(a) as two from tm;
  101. select max(a) as one from ti;
  102. set @@global.debug="-d";
  103. #
  104. # clean-up
  105. #
  106. # the sql thread has an error, so reset replication state
  107. --let $rpl_only_running_threads= 1
  108. --source include/rpl_reset.inc
  109. connection master;
  110. drop table tm, ti;
  111. --sync_slave_with_master