| 1 |
# |
| 2 |
# ==== Purpose ==== |
| 3 |
# |
| 4 |
# WL#6559 Optimize GTIDs for passive slave - store GTIDs in table |
| 5 |
# |
| 6 |
# Added test cases to cover error branches. |
| 7 |
# |
| 8 |
# Test case 1: Simulate an error on writing gtids into table on |
| 9 |
# server shutdown, verify that we can get correct |
| 10 |
# gtid sets after server restarts. |
| 11 |
# Test case 2: Simulate an error on writing gtids into table on |
| 12 |
# binlog rotation, verify that GTIDs are not saved |
| 13 |
# into gtid_executed table. |
| 14 |
# |
| 15 |
|
| 16 |
--source include/not_valgrind.inc |
| 17 |
--source include/have_debug.inc |
| 18 |
--source include/have_log_bin.inc |
| 19 |
|
| 20 |
# Need to restart servers after this test because it closes the binary |
| 21 |
# log and there is no other way to recover from that. |
| 22 |
--source include/force_restart.inc |
| 23 |
|
| 24 |
RESET MASTER; |
| 25 |
SET @@GLOBAL.DEBUG= "+d,simulate_err_on_write_gtid_into_table"; |
| 26 |
|
| 27 |
call mtr.add_suppression("Failed to save the set of Global Transaction " |
| 28 |
"Identifiers of the last binary log into the " |
| 29 |
"mysql.gtid_executed table while the server was " |
| 30 |
"shutting down. The next server restart will make " |
| 31 |
"another attempt to save Global Transaction " |
| 32 |
"Identifiers into the table."); |
| 33 |
SET @debug_save= @@GLOBAL.DEBUG; |
| 34 |
--let $saved_binlog_error_action=`SELECT @@GLOBAL.binlog_error_action` |
| 35 |
--let $master_uuid= `SELECT @@GLOBAL.SERVER_UUID` |
| 36 |
CREATE TABLE t1 (a INT) ENGINE=InnoDB; |
| 37 |
|
| 38 |
--source include/restart_mysqld.inc |
| 39 |
|
| 40 |
--echo # |
| 41 |
--echo # Verify that we can get correct gtid sets after server restarts |
| 42 |
--echo # even if we encounter an error on writing gtids into table on |
| 43 |
--echo # server shutdown. |
| 44 |
--echo # |
| 45 |
--let $assert_text= committed gtid set is MASTER_UUID:1-2 |
| 46 |
--let $assert_cond= @@GLOBAL.GTID_EXECUTED = "$master_uuid:1-2" |
| 47 |
--source include/assert.inc |
| 48 |
--replace_result $master_uuid MASTER_UUID |
| 49 |
SELECT * FROM mysql.gtid_executed; |
| 50 |
SET GLOBAL DEBUG= @debug_save; |
| 51 |
SET GLOBAL binlog_error_action= IGNORE_ERROR; |
| 52 |
|
| 53 |
SET GLOBAL debug="+d,simulate_err_on_write_gtid_into_table"; |
| 54 |
call mtr.add_suppression(".* Turning logging off for the whole duration of the " |
| 55 |
"MySQL server process. To turn it on again: fix the " |
| 56 |
"cause, shutdown the MySQL server and restart it."); |
| 57 |
call mtr.add_suppression("ERROR.*Unable to create a new binlog file: Table " |
| 58 |
"`mysql.gtid_executed` couldn't be opened. Current" |
| 59 |
" binlog file was flushed to disk and will be kept" |
| 60 |
" in use."); |
| 61 |
|
| 62 |
INSERT INTO t1 VALUES(1); |
| 63 |
SET GLOBAL debug="+d,wait_for_flush_gtid_persister"; |
| 64 |
--replace_regex /'Unknown error.*'/'Unknown error'/ |
| 65 |
--ERROR ER_GET_ERRNO |
| 66 |
FLUSH LOGS; |
| 67 |
SET GLOBAL debug="-d,wait_for_flush_gtid_persister"; |
| 68 |
SET GLOBAL debug="-d,simulate_err_on_write_gtid_into_table"; |
| 69 |
--echo # |
| 70 |
--echo # Verify that GTIDs are not saved into gtid_executed table if we |
| 71 |
--echo # encounter an error on writing gtids into table on binlog rotation. |
| 72 |
--echo # |
| 73 |
--replace_result $master_uuid MASTER_UUID |
| 74 |
SELECT * FROM mysql.gtid_executed; |
| 75 |
--let $assert_text= committed gtid set is MASTER_UUID:1-5 |
| 76 |
--let $assert_cond= @@GLOBAL.GTID_EXECUTED = "$master_uuid:1-5" |
| 77 |
--source include/assert.inc |
| 78 |
--eval SET GLOBAL binlog_error_action= $saved_binlog_error_action |
| 79 |
|
| 80 |
DROP TABLE t1; |