polardbxengine/mysql-test/suite/binlog_gtid/t/binlog_gtids_table_gcov.test

81 lines
3.2 KiB
Plaintext

#
# ==== Purpose ====
#
# WL#6559 Optimize GTIDs for passive slave - store GTIDs in table
#
# Added test cases to cover error branches.
#
# Test case 1: Simulate an error on writing gtids into table on
# server shutdown, verify that we can get correct
# gtid sets after server restarts.
# Test case 2: Simulate an error on writing gtids into table on
# binlog rotation, verify that GTIDs are not saved
# into gtid_executed table.
#
--source include/not_valgrind.inc
--source include/have_debug.inc
--source include/have_log_bin.inc
# Need to restart servers after this test because it closes the binary
# log and there is no other way to recover from that.
--source include/force_restart.inc
RESET MASTER;
SET @@GLOBAL.DEBUG= "+d,simulate_err_on_write_gtid_into_table";
call mtr.add_suppression("Failed to save the set of Global Transaction "
"Identifiers of the last binary log into the "
"mysql.gtid_executed table while the server was "
"shutting down. The next server restart will make "
"another attempt to save Global Transaction "
"Identifiers into the table.");
SET @debug_save= @@GLOBAL.DEBUG;
--let $saved_binlog_error_action=`SELECT @@GLOBAL.binlog_error_action`
--let $master_uuid= `SELECT @@GLOBAL.SERVER_UUID`
CREATE TABLE t1 (a INT) ENGINE=InnoDB;
--source include/restart_mysqld.inc
--echo #
--echo # Verify that we can get correct gtid sets after server restarts
--echo # even if we encounter an error on writing gtids into table on
--echo # server shutdown.
--echo #
--let $assert_text= committed gtid set is MASTER_UUID:1-2
--let $assert_cond= @@GLOBAL.GTID_EXECUTED = "$master_uuid:1-2"
--source include/assert.inc
--replace_result $master_uuid MASTER_UUID
SELECT * FROM mysql.gtid_executed;
SET GLOBAL DEBUG= @debug_save;
SET GLOBAL binlog_error_action= IGNORE_ERROR;
SET GLOBAL debug="+d,simulate_err_on_write_gtid_into_table";
call mtr.add_suppression(".* Turning logging off for the whole duration of the "
"MySQL server process. To turn it on again: fix the "
"cause, shutdown the MySQL server and restart it.");
call mtr.add_suppression("ERROR.*Unable to create a new binlog file: Table "
"`mysql.gtid_executed` couldn't be opened. Current"
" binlog file was flushed to disk and will be kept"
" in use.");
INSERT INTO t1 VALUES(1);
SET GLOBAL debug="+d,wait_for_flush_gtid_persister";
--replace_regex /'Unknown error.*'/'Unknown error'/
--ERROR ER_GET_ERRNO
FLUSH LOGS;
SET GLOBAL debug="-d,wait_for_flush_gtid_persister";
SET GLOBAL debug="-d,simulate_err_on_write_gtid_into_table";
--echo #
--echo # Verify that GTIDs are not saved into gtid_executed table if we
--echo # encounter an error on writing gtids into table on binlog rotation.
--echo #
--replace_result $master_uuid MASTER_UUID
SELECT * FROM mysql.gtid_executed;
--let $assert_text= committed gtid set is MASTER_UUID:1-5
--let $assert_cond= @@GLOBAL.GTID_EXECUTED = "$master_uuid:1-5"
--source include/assert.inc
--eval SET GLOBAL binlog_error_action= $saved_binlog_error_action
DROP TABLE t1;