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.

77 lines
2.6 KiB

  1. # When the relay log gets rotated while the I/O thread
  2. # is reading a transaction, the transaction spans on two or more
  3. # relay logs. If STOP SLAVE occurs while the SQL thread is
  4. # executing a part of the transaction in the non-first relay logs,
  5. # we test if START SLAVE will resume in the beginning of the
  6. # transaction (i.e., step back to the first relay log)
  7. # The slave is started with max_binlog_size=16384 bytes,
  8. # to force many rotations (approximately 30 rotations)
  9. # We have to sync with master, to ensure slave had time to start properly
  10. # before we stop it. If not, we get errors about UNIX_TIMESTAMP() in the log.
  11. connection master;
  12. sync_slave_with_master;
  13. connection slave;
  14. stop slave;
  15. connection master;
  16. --disable_warnings
  17. eval create table t1 (a int) engine=$engine_type;
  18. --enable_warnings
  19. let $1=8000;
  20. disable_query_log;
  21. begin;
  22. while ($1)
  23. {
  24. # eval means expand $ expressions
  25. eval insert into t1 values( $1 );
  26. dec $1;
  27. }
  28. commit;
  29. # This will generate a 500kB master's binlog,
  30. # which corresponds to 30 slave's relay logs.
  31. enable_query_log;
  32. save_master_pos;
  33. connection slave;
  34. reset slave;
  35. start slave;
  36. # We wait 1 sec for the SQL thread to be somewhere in
  37. # the middle of the transaction, hopefully not in
  38. # the first relay log, and hopefully before the COMMIT.
  39. # Usually it stops when the SQL thread is around the 15th relay log.
  40. # We cannot use MASTER_POS_WAIT() as master's position
  41. # increases only when the slave executes the COMMIT.
  42. # Note that except when using Valgrind, 1 second is enough for the I/O slave
  43. # thread to fetch the whole master's binlog.
  44. sleep 1;
  45. stop slave;
  46. # We suppose the SQL thread stopped before COMMIT.
  47. # If so the transaction was rolled back
  48. # and the table is now empty.
  49. # Now restart
  50. start slave;
  51. # And see if the table contains '8000'
  52. # which proves that the transaction restarted at
  53. # the right place.
  54. # We must wait for the transaction to commit before
  55. # reading, with a sync_with_master.
  56. sync_with_master;
  57. select max(a) from t1;
  58. connection master;
  59. # The following DROP is a very important cleaning task:
  60. # imagine the next test is run with --skip-innodb: it will do
  61. # DROP TABLE IF EXISTS t1; but this will delete the frm and leave
  62. # some data in the InnoDB datafile (because at that time mysqld
  63. # does not know about InnoDB : --skip-innodb). So if later in the
  64. # test suite a test wants to create an InnoDB table called t1, it
  65. # will fail with
  66. # InnoDB: Error: table t1 already exists in InnoDB internal
  67. # InnoDB: data dictionary. Have you deleted the .frm file etc
  68. drop table t1;
  69. # wait until this drop is executed on slave
  70. save_master_pos;
  71. connection slave;
  72. sync_with_master;
  73. # End of 4.1 tests