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.

108 lines
2.1 KiB

Fix for BUG#13023: "SQL Thread is up but doesn't move forward". Details in slave.cc; in short we now record whenever the slave I/O thread ignores a master's event because of its server id, and use this info in the slave SQL thread to advance Exec_master_log_pos. Because if we do not, this variable stays at the position of the last executed event, i.e. the last *non-ignored* executed one, which may not be the last of the master's binlog (and so the slave *looks* behind the master though it's data-wise it's not). mysql-test/t/rpl_dual_pos_advance-master.opt: empty; its goal is just to trigger a server restart after running the test, so that the master forgets that it was a slave (otherwise it affects the following tests). sql/log.cc: No more default arguments for Rotate_log_event constructor. MYSQL_LOG::appendv() is now called without mutex. sql/log_event.cc: Moving one Rotate_log_event constructor from log_event.h. Support for on-demand choice of duplicating the string argument of the constructor or not (because there now are needs for both alternatives, see slave.cc). sql/log_event.h: We now have a case where a Rotate_log_event is executed by the slave SQL thread while not being in the relay log, so it needs to pretend its length is 0: a ZERO_LEN flag for that; a flag DUP_NAME (replaces "bool alloced") to be able to choose if we want the constructor to duplicate the string argument or not. sql/slave.cc: A comment for BUG#13861 (to be fixed). llstr() instead of %ld as the number is ulonglong. mi->rli becomes rli in some places. Fix for BUG#13023: - in the slave I/O thread, whenever we ignore an event because of its server id we update a couple of coordinates in memory - in the slave SQL thread, whenever we bump into the end of the latest relay log, we check this couple of coordinates to see if we should advance our Exec_master_log_pos. - when the slave I/O thread terminates it saves these in-memory coordinates into a Rotate event in the relay log, so that they are durable. sql/slave.h: A couple of coordinates in RELAY_LOG_INFO to keep track of the last ignored events received by the slave I/O thread (ignored because of the server id). mysql-test/r/rpl_dual_pos_advance.result: New BitKeeper file ``mysql-test/r/rpl_dual_pos_advance.result'' mysql-test/t/rpl_dual_pos_advance.test: Test for BUG#13023 (with a part, disabled, to test BUG#13861 when I fix it). Before the fix, this test used to hang.
20 years ago
  1. # This test checks that in a dual-head setup
  2. # A->B->A, where A has --log-slave-updates (why would it?
  3. # assume that there is a C as slave of A),
  4. # then the Exec_master_log_pos of SHOW SLAVE STATUS does
  5. # not stay too low on B(BUG#13023 due to events ignored because
  6. # of their server id).
  7. # It also will test BUG#13861.
  8. source include/master-slave.inc;
  9. # set up "dual head"
  10. connection slave;
  11. reset master;
  12. connection master;
  13. --replace_result $SLAVE_MYPORT SLAVE_PORT
  14. eval change master to master_host="127.0.0.1",master_port=$SLAVE_MYPORT,master_user="root";
  15. start slave;
  16. # now we test it
  17. connection slave;
  18. create table t1 (n int);
  19. save_master_pos;
  20. connection master;
  21. sync_with_master;
  22. # Now test BUG#13861. This will be enabled when Guilhem fixes this
  23. # bug.
  24. # stop slave
  25. # create table t2 (n int); # create one ignored event
  26. # save_master_pos;
  27. # connection slave;
  28. # sync_with_master;
  29. # connection slave;
  30. # show tables;
  31. # save_master_pos;
  32. # create table t3 (n int);
  33. # connection master;
  34. # bug is that START SLAVE UNTIL may stop too late, we test that by
  35. # asking it to stop before creation of t3.
  36. # start slave until master_log_file="slave-bin.000001",master_log_pos=195;
  37. # wait until it's started (the position below is the start of "CREATE
  38. # TABLE t2") (otherwise wait_for_slave_to_stop may return at once)
  39. # select master_pos_wait("slave-bin.000001",137);
  40. # wait_for_slave_to_stop;
  41. # then BUG#13861 causes t3 to show up below (because stopped too
  42. # late).
  43. # show tables;
  44. # start slave;
  45. # BUG#13023 is that Exec_master_log_pos may stay too low "forever":
  46. connection master;
  47. create table t4 (n int); # create 3 ignored events
  48. create table t5 (n int);
  49. create table t6 (n int);
  50. save_master_pos;
  51. connection slave;
  52. sync_with_master;
  53. connection slave;
  54. save_master_pos;
  55. connection master;
  56. # then BUG#13023 caused hang below ("master" looks behind, while it's
  57. # not in terms of updates done).
  58. sync_with_master;
  59. show tables;
  60. # cleanup
  61. stop slave;
  62. reset slave;
  63. drop table t1,t4,t5,t6; # add t2 and t3 later
  64. save_master_pos;
  65. connection slave;
  66. sync_with_master;
  67. # End of 4.1 tests