############################################################################### # Bug#21276561: FAILURE TO GENERATE GTID LEADS TO INCONSISTENCY # # Problem: # ======= # If generating a GTID for a transaction fails, the transaction is not written # to the binary log but still gets committed, which potentially leads to # master/slave data inconsistency. # # Test: # ===== # Simulate a scenario such that generation of GTID number reaches its maximum # value and the new GTID cannot be generated because of that. Verify that this # fatal error case is appropriately handled as per the binlog_error_action # value specified by user. ############################################################################### # This test case is binlog_format agnostic --source include/have_binlog_format_statement.inc # Don't test this under valgrind, memory leaks will occur --source include/not_valgrind.inc call mtr.add_suppression("An error occurred during flush stage of the commit"); call mtr.add_suppression("Attempting backtrace. You can use the following information to find out"); --let $assert_file = $MYSQLTEST_VARDIR/tmp/binlog_gtid_exhausted.err #Test case 1: SET GLOBAL binlog_error_action=IGNORE_ERROR; CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB; # @@GLOBAL.GTID_PURGED can only be set when @@GLOBAL.GTID_EXECUTED is empty. # Hence execute RESET MASTER. RESET MASTER; SET GLOBAL gtid_purged = CONCAT(@@GLOBAL.server_uuid, ':1-9223372036854775805'); INSERT INTO t1 VALUES (1); --error ER_GNO_EXHAUSTED INSERT INTO t1 VALUES (2); # BUG26035544 Assert that an error was logged to the server error log. --let $assert_select = Impossible to generate GTID: the integer component reached the maximum value. Restart the server with a new server_uuid. Hence 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. --let $assert_count = 1 --let $assert_text = ER_GNO_EXHAUSTED found in server error log --source include/assert_grep.inc # Check that transaction is committed --let $assert_cond = COUNT(*) = 2 FROM t1; --let $assert_text = Count of elements in t1 should be 2. --source include/assert.inc --source include/restart_mysqld.inc RESET MASTER; DROP TABLE t1; #Test case 2: CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB; # @@GLOBAL.GTID_PURGED can only be set when the new value # includes the old one and their set difference does not overlap with # @@GLOBAL.GTID_EXECUTED. # RESET MASTER empties the latter and the current purged set # to satisfy the above condition. RESET MASTER; # BUG#20470724 owes this check of no binlog rotation after SET --let $binlog_file_0= query_get_value(SHOW MASTER STATUS, File, 1) SET GLOBAL gtid_purged = CONCAT(@@GLOBAL.server_uuid, ':1-9223372036854775805'); --let $binlog_file_1= query_get_value(SHOW MASTER STATUS, File, 1) --let $assert_cond = "$binlog_file_0" = "$binlog_file_1" --let $assert_text = Binlog file must not rotate after SET GTID_PURGED --source include/assert.inc INSERT INTO t1 VALUES (1); SET GLOBAL binlog_error_action=ABORT_SERVER; --exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --error ER_BINLOG_LOGGING_IMPOSSIBLE INSERT INTO t1 VALUES (2); --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --enable_reconnect --source include/wait_until_connected_again.inc RESET MASTER; DROP TABLE t1; ## BUG26035544 Assert that an error was logged to the server error log. --let $assert_select = Binary logging not possible. Message: Impossible to generate GTID: the integer component reached the maximum value. Restart the server with a new server_uuid. Server is being stopped. --let $assert_count = 1 --let $assert_text = ER_GNO_EXHAUSTED server is being stopped found in server error log --source include/assert_grep.inc ############################################################################## # ==== Purpose ==== # The purpose of this test is to verify that warning message is logged into # server error log when GTID.GNO breaches the threshold limit. # # ==== Requirements ==== # Generate a warning message when GTID.GNO getting close to Max limit # (i.e the last 1% of the range [(LLONG_MAX/100)*99]) # # ==== Implementation ==== # 1. Set GTID value > Threshold[(LLONG_MAX/100)*99] # - Update GTID value by executing SET GTID_PURGED. # - Verify that warning message is logged into the error log. # - Perform a transaction. # - Verify that warning messages is logged into the error log. # 2. Set GTID value < Threshold[(LLONG_MAX/100)*99] # - Update GTID value by executing SET GTID_PURGED. # - Perform a transaction. # - Verify that no warning message is logged into the error log. # # ==== References ==== # Bug#26035544: 'BINLOG_ERROR_ACTION' IS SET TO 'ABORT_SERVER'. HENCE ABORTING # THE SERVER # ############################################################################### --source include/shutdown_mysqld.inc --remove_file $MYSQLTEST_VARDIR/tmp/binlog_gtid_exhausted.err --source include/start_mysqld.inc --let $server_uuid = `SELECT @@GLOBAL.SERVER_UUID` --let $assert_file = $MYSQLTEST_VARDIR/tmp/binlog_gtid_exhausted.err --let $assert_select = The integer component of the GTID number is high. # Test case 3: # Test scenario set GTID > Threshold[(LLONG_MAX/100)*99]. RESET MASTER; --disable_query_log --eval SET GLOBAL gtid_purged = CONCAT('$server_uuid:1-', (1 << 63) - 10); --enable_query_log CREATE TABLE t1(i INT); # Cleanup DROP TABLE t1; # Assert that a warning was logged to the server error log. --let $assert_count = 3 --let $assert_text = ER_WARN_GTID_THRESHOLD_BREACH found in server error log --source include/assert_grep.inc # Test case 4: # Test scenario set GTID < Threshold. RESET MASTER; --disable_query_log --eval SET GLOBAL gtid_purged = CONCAT('$server_uuid:1-', (1 << 63) - (1 << 57)); --enable_query_log CREATE TABLE t1(i INT); # Assert that no new GTID_THRESHOLD_BREACH warning was logged to the server error log. --let $assert_count= 3 --let $assert_text = No new ER_WARN_GTID_THRESHOLD_BREACH found in server error log --source include/assert_grep.inc # Cleanup DROP TABLE t1; ############################################################################## # ==== Purpose ==== # The purpose of this test is to verify that, when user executes # SET gtid_purged, GTID threshold breach warning message should be raised # only based on the number of GTIDs in the server_uuid instead of counting # all UUIDs. # # ==== Requirements ==== # A SET gtid_purged statement should not generate a warning when the range of # GTIDs for server_uuid is below the limit, even if the total number of GTIDs # taking all UUIDs into account exceeds the threshold. # # ==== Implementation ==== # 1. Single UUID other than server_uuid have less GTIDs than the # Threshold[(INT64_MAX/100)*99] and total number of GTIDs > Threshold # - Set server_uuid with a dummy value and GTID.GNO value below # Threshold by executing SET GTID_PURGED. # - Set server_uuid as @@GLOBAL.SERVER_UUID and GTID.GNO value below # Threshold in such a way that total number of GTDs (server_uuid's # GTID.GNO + previoulsy purged GTIDs) > Threshold # - Verify that no warning messages is logged into the error log. # # 2. Single UUID other than server_uuid have more GTIDs than the # Threshold[(INT64_MAX/100)*99] # - Set server_uuid with a dummy value and GTID.GNO value greater than # Threshold by executing SET GTID_PURGED. # - Set server_uuid as @@GLOBAL.SERVER_UUID and set GTID.GNO value below # Threshold # - Verify that no new warning messages is logged into the error log. # # ==== References ==== # Bug#:32086209: INCORRECT DECISION TO CLONE OR RECOVER WHEN GTID # DIFFERENCE IS HUGE # ############################################################################### --source include/shutdown_mysqld.inc --remove_file $MYSQLTEST_VARDIR/tmp/binlog_gtid_exhausted.err --source include/start_mysqld.inc --let $server_uuid = `SELECT @@server_uuid` --let $dummy_server_uuid = dddddddd-dddd-dddd-dddd-dddddddddddd --let $assert_file = $MYSQLTEST_VARDIR/tmp/binlog_gtid_exhausted.err --let $assert_select = The integer component of the GTID number is high. # Test scenario 1: RESET MASTER; # Set server_uuid as dummy and GTID value below Threshold. --eval SET GLOBAL gtid_purged = CONCAT('$dummy_server_uuid:1-', (1 << 62)) # Set server_uuid as @@GLOBAL.SERVER_UUID and GTID below Threshold. --replace_result $server_uuid SERVER_UUID --eval SET GLOBAL gtid_purged = CONCAT('+$server_uuid:1-', (1 << 62)) # Assert that no new warning was logged to the server error log. --let $assert_count = 0 --let $assert_text = No ER_WARN_GTID_THRESHOLD_BREACH found in server error log --source include/assert_grep.inc # Test scenario 2: RESET MASTER; # Set server_uuid as dummy and GTID value above Threshold. --eval SET GLOBAL gtid_purged = CONCAT('$dummy_server_uuid:1-', (1 << 63) - 2) # Set server_uuid as @@GLOBAL.SERVER_UUID GTID below Threshold. --replace_result $server_uuid SERVER_UUID --eval SET GLOBAL gtid_purged = CONCAT('+$server_uuid:1-25') # Assert that no new warning was logged to the server error log. --let $assert_count = 0 --let $assert_text = No new ER_WARN_GTID_THRESHOLD_BREACH found in server error log --source include/assert_grep.inc # Cleanup --source include/restart_mysqld.inc