######################################## # ==== Purpose ==== # # Verify that a partially failed statement can consume # its gtid and save the gtid into @@GLOBAL.GTID_EXECUTED # and mysql.gtid_executed table when binlog is disabled # if it did the same when binlog is enabled. # # Also provides coverage for changes to GTID handling for failed # DROP TABLES, which were implemented as part of WL#7743 "New data # dictionary: changes to DDL-related parts of SE API". # # ==== Implementation ==== # # 1) SET SESSION GTID_NEXT='UUID:GNO'. # 2) Execute a partially failed statement. # 3) Verify that the partially failed statement can consume # its gtid and save the gtid into @@GLOBAL.GTID_EXECUTED # and mysql.gtid_executed table when binlog is disabled # if it did the same when binlog is enabled. # 4) Execute above three steps for all different types of statements # # ==== References ==== # # Bug#21686749 PARTIALLY FAILED DROP OR ACL STMT FAILS TO CONSUME GTID ON BINLOGLESS SLAVE # See mysql-test/suite/binlog/t/binlog_gtid_next_partially_failed_stmts.test # See mysql-test/suite/binlog/t/binlog_gtid_next_partially_failed_grant.test # See mysql-test/t/no_binlog_gtid_next_partially_failed_stmts_error.test # # The test involves MyISAM sorage engine --source include/force_myisam_default.inc --source include/have_myisam.inc # Should be tested against "binlog disabled" server --source include/not_log_bin.inc # Requires debug server to simulate failure to drop table in SE --source include/have_debug.inc # Make sure the test is repeatable RESET MASTER; --let $master_uuid= `SELECT @@GLOBAL.SERVER_UUID` --replace_result $master_uuid MASTER_UUID --eval SET SESSION GTID_NEXT='$master_uuid:1' CREATE TABLE t1 (a int) ENGINE=MyISAM; --replace_result $master_uuid MASTER_UUID --eval SET SESSION GTID_NEXT='$master_uuid:2' CREATE TABLE t5 (a int) ENGINE=InnoDB; # Check-1: DROP TABLE --replace_result $master_uuid MASTER_UUID --eval SET SESSION GTID_NEXT='$master_uuid:3' --echo # --echo # Original test case. --echo # --echo # The below DROP TABLE has partially failed before WL#7743. --echo # Now if fails without side-effects and thus should not consume gitd. --echo # --error ER_BAD_TABLE_ERROR DROP TABLE t1, t3; --echo # --echo # The table t1 was not dropped. --echo # SHOW CREATE TABLE t1; --echo # --echo # Verify that the above DROP TABLE statement has not consumed gtid. --echo # --let $assert_text= Committed gtid MASTER_UUID:2 into @@GLOBAL.GTID_EXECUTED --let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$master_uuid:1-2" --source include/assert.inc --eval SET SESSION GTID_NEXT='AUTOMATIC' FLUSH LOGS; --let $assert_text= Saved gtid MASTER_UUID:2 into mysql.gtid_executed table --let $assert_cond= "[SELECT COUNT(*) FROM mysql.gtid_executed WHERE interval_end = 2]" = 1 --source include/assert.inc --echo # --echo # Now we simulate error after dropping MyISAM table. In this case --echo # DROP TABLE is partially executed/failed and should consume gtid. --echo # SET @@debug="+d,rm_table_no_locks_abort_before_atomic_tables"; --replace_result $master_uuid MASTER_UUID --eval SET SESSION GTID_NEXT='$master_uuid:3' --error ER_UNKNOWN_ERROR DROP TABLE t1, t5; SET @@debug="-d,rm_table_no_locks_abort_before_atomic_tables"; --echo # --echo # The above DROP TABLE should have deleted t1. --echo # --error ER_NO_SUCH_TABLE SHOW CREATE TABLE t1; --echo # --echo # Verify that the partially failed DROP TABLE statement can consume --echo # its gtid and save the gtid into @@GLOBAL.GTID_EXECUTED and --echo # mysql.gtid_executed table when binlog is disabled as it did when --echo # binlog is enabled. --echo # --let $assert_text= Committed gtid MASTER_UUID:2 into @@GLOBAL.GTID_EXECUTED --let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$master_uuid:1-3" --source include/assert.inc --eval SET SESSION GTID_NEXT='AUTOMATIC' FLUSH LOGS; --let $assert_text= Saved gtid MASTER_UUID:2 into mysql.gtid_executed table --let $assert_cond= "[SELECT COUNT(*) FROM mysql.gtid_executed WHERE interval_end = 3]" = 1 --source include/assert.inc --replace_result $master_uuid MASTER_UUID --eval SET SESSION GTID_NEXT='$master_uuid:4' CREATE TEMPORARY TABLE tmp1 (a int); # Check-2: DROP TEMPORARY TABLE --replace_result $master_uuid MASTER_UUID --eval SET SESSION GTID_NEXT='$master_uuid:5' --echo # --echo # The below DROP TEMPORARY TABLE has partially failed before WL#7743. --echo # Now if fails without side-effects and thus should not consume gitd. --echo # --echo # There is no way for DROP TEMPORARY TABLE to partially fail now, --echo # so unlike for DROP TABLE, there is no way to test scenario with --echo # partial failure for it. --error ER_BAD_TABLE_ERROR DROP TEMPORARY TABLE tmp1, t2; --echo # --echo # Verify that failed DROP TEMPORARY TABLE statement has not --echo # consumed its gtid. --echo # --let $assert_text= Committed gtid MASTER_UUID:4 into @@GLOBAL.GTID_EXECUTED --let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$master_uuid:1-4" --source include/assert.inc --eval SET SESSION GTID_NEXT='AUTOMATIC' FLUSH LOGS; --let $assert_text= Saved gtid MASTER_UUID:4 into mysql.gtid_executed table --let $assert_cond= "[SELECT COUNT(*) FROM mysql.gtid_executed WHERE interval_end = 4]" = 1 --source include/assert.inc --replace_result $master_uuid MASTER_UUID --eval SET SESSION GTID_NEXT='$master_uuid:5' CREATE TABLE t1(a INT, b INT); --replace_result $master_uuid MASTER_UUID --eval SET SESSION GTID_NEXT='$master_uuid:6' CREATE USER u1@h; --echo # --echo # Verify that u1 is added into mysql.user. --echo # SELECT user FROM mysql.user where user='u1'; # Check-3: GRANT a non-available privilege --replace_result $master_uuid MASTER_UUID --eval SET SESSION GTID_NEXT='$master_uuid:7' --error ER_BAD_FIELD_ERROR GRANT SELECT(a), SELECT(c) ON t1 TO u1@h; --echo # --echo # The SELECT privilege on column a is not granted to u1@h, --echo # which means that GRANT can not be failed partially when --echo # granting an available privilege and a non-available --echo # privilege to an existent user. --echo # SELECT user, column_name, column_priv FROM mysql.columns_priv; --echo # --echo # Verify that the failed GRANT statement does not save --echo # the specified gtid into @@GLOBAL.GTID_EXECUTED and --echo # mysql.gtid_executed table. --echo # --replace_result $master_uuid MASTER_UUID --let $assert_text= Did not commit gtid MASTER_UUID:7 into @@GLOBAL.GTID_EXECUTED --let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$master_uuid:1-6" --source include/assert.inc --eval SET SESSION GTID_NEXT='AUTOMATIC' FLUSH LOGS; --let $assert_text= Did not save gtid MASTER_UUID:7 into mysql.gtid_executed table --let $assert_cond= "[SELECT COUNT(*) FROM mysql.gtid_executed WHERE interval_end = 7]" = 0 --source include/assert.inc # Check-4: GRANT a privilege to a non-existent user --replace_result $master_uuid MASTER_UUID --eval SET SESSION GTID_NEXT='$master_uuid:7' --error ER_CANT_CREATE_USER_WITH_GRANT GRANT SELECT(a) ON t1 TO u1@h, u2@h; --echo # --echo # The SELECT privilege on column a is not granted to u1@h, --echo # which means that GRANT can not fail partially when --echo # granting an available privilege to both an existent --echo # user and a non-existent user. --echo # SELECT user, column_name, column_priv FROM mysql.columns_priv; --echo # --echo # Verify that the failed GRANT statement does not save --echo # the specified gtid into @@GLOBAL.GTID_EXECUTED and --echo # mysql.gtid_executed table. --echo # --replace_result $master_uuid MASTER_UUID --let $assert_text= Did not commit gtid MASTER_UUID:7 into @@GLOBAL.GTID_EXECUTED --let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$master_uuid:1-6" --source include/assert.inc --eval SET SESSION GTID_NEXT='AUTOMATIC' FLUSH LOGS; --let $assert_text= Did not save gtid MASTER_UUID:7 into mysql.gtid_executed table --let $assert_cond= "[SELECT COUNT(*) FROM mysql.gtid_executed WHERE interval_end = 7]" = 0 --source include/assert.inc # Check-5: REVOKE --replace_result $master_uuid MASTER_UUID --eval SET SESSION GTID_NEXT='$master_uuid:7' --error ER_NONEXISTING_TABLE_GRANT REVOKE SELECT(a), SELECT(b) ON t1 FROM u1@h; --echo # --echo # The SELECT privilege is not removed on column a from user u1, --echo # which means that REVOKE statement can not fail partially --echo # when revoking multiple privileges from a user. --echo # SELECT user, column_name, column_priv FROM mysql.columns_priv; --echo # --echo # Verify that the failed REVOKE statement does not save --echo # the specified gtid into @@GLOBAL.GTID_EXECUTED and --echo # and mysql.gtid_executed table. --echo # --replace_result $master_uuid MASTER_UUID --let $assert_text= Did not commit gtid MASTER_UUID:7 into @@GLOBAL.GTID_EXECUTED --let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$master_uuid:1-6" --source include/assert.inc --eval SET SESSION GTID_NEXT='AUTOMATIC' FLUSH LOGS; --let $assert_text= Did not save gtid MASTER_UUID:7 into mysql.gtid_executed table --let $assert_cond= "[SELECT COUNT(*) FROM mysql.gtid_executed WHERE interval_end = 7]" = 0 --source include/assert.inc # Check-6: DROP USER --replace_result $master_uuid MASTER_UUID --eval SET SESSION GTID_NEXT='$master_uuid:7' --error ER_CANNOT_USER DROP USER u1@h, u2@h; --echo # --echo # The u1 is not removed from mysql.user which means that DROP USER --echo # can not fail partially. --echo # SELECT user FROM mysql.user where user='u1'; --echo # --echo # Verify that the failed DROP USER statement does not consume --echo # its gtid and save the gtid into @@GLOBAL.GTID_EXECUTED and --echo # mysql.gtid_executed table. --echo # --replace_result $master_uuid MASTER_UUID --let $assert_text= Did not commit gtid MASTER_UUID:7 into @@GLOBAL.GTID_EXECUTED --let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$master_uuid:1-6" --source include/assert.inc --eval SET SESSION GTID_NEXT='AUTOMATIC' FLUSH LOGS; --let $assert_text= Did not save gtid MASTER_UUID:7 into mysql.gtid_executed table --let $assert_cond= "[SELECT COUNT(*) FROM mysql.gtid_executed WHERE interval_end = 7]" = 0 --source include/assert.inc # Check-7: RENAME TABLE --replace_result $master_uuid MASTER_UUID --eval SET SESSION GTID_NEXT='$master_uuid:7' --error ER_NO_SUCH_TABLE RENAME TABLE t1 TO t2, t3 TO t4; --echo # --echo # The table t1 was not renamed, which means RENAME TABLE --echo # can not be failed partially. --echo # SHOW CREATE TABLE t1; --echo # --echo # Verify that the failed RENAME TABLE statement does not save --echo # the specified gtid into @@GLOBAL.GTID_EXECUTED and --echo # mysql.gtid_executed table when binlog is disabled as it did --echo # when binlog is enabled. --echo # --replace_result $master_uuid MASTER_UUID --let $assert_text= Did not commit gtid MASTER_UUID:7 into @@GLOBAL.GTID_EXECUTED --let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$master_uuid:1-6" --source include/assert.inc --eval SET SESSION GTID_NEXT='AUTOMATIC' FLUSH LOGS; --let $assert_text= Did not save gtid MASTER_UUID:7 into mysql.gtid_executed table --let $assert_cond= "[SELECT COUNT(*) FROM mysql.gtid_executed WHERE interval_end = 7]" = 0 --source include/assert.inc # Check-8: OPTIMIZE TABLE --echo # --echo # The OPTIMIZE TABLE statement can be failed partially when optimizing --echo # multiple tables, which contain a non-existent table. --echo # --replace_result $master_uuid MASTER_UUID --eval SET SESSION GTID_NEXT='$master_uuid:7' OPTIMIZE TABLE t1, t_non_existent; --echo # --echo # When optimizing a non-existent table, verify that the OPTIMIZE TABLE --echo # statement saves its specified gtid into @@GLOBAL.GTID_EXECUTED and --echo # mysql.gtid_executed table when binlog is disabled as it did --echo # when binlog is enabled. --echo # --replace_result $master_uuid MASTER_UUID --let $assert_text= Committed gtid MASTER_UUID:7 into @@GLOBAL.GTID_EXECUTED --let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$master_uuid:1-7" --source include/assert.inc --eval SET SESSION GTID_NEXT='AUTOMATIC' FLUSH LOGS; --let $assert_text= Saved gtid MASTER_UUID:7 into mysql.gtid_executed table --let $assert_cond= "[SELECT COUNT(*) FROM mysql.gtid_executed WHERE interval_end = 7]" = 1 --source include/assert.inc # Check-9: ANALYZE TABLE --echo # --echo # The ANALYZE TABLE statement can be failed partially when analyzingu --echo # multiple tables, which contain a non-existent table. --echo # --replace_result $master_uuid MASTER_UUID --eval SET SESSION GTID_NEXT='$master_uuid:8' ANALYZE TABLE t1, t_non_existent; --echo # --echo # When analyzing a non-existent table, verify that the ANALYZE TABLE --echo # statement saves its specified gtid into @@GLOBAL.GTID_EXECUTED and --echo # mysql.gtid_executed table when binlog is disabled as it did --echo # when binlog is enabled. --echo # --replace_result $master_uuid MASTER_UUID --let $assert_text= Committed gtid MASTER_UUID:8 into @@GLOBAL.GTID_EXECUTED --let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$master_uuid:1-8" --source include/assert.inc --eval SET SESSION GTID_NEXT='AUTOMATIC' FLUSH LOGS; --let $assert_text= Saved gtid MASTER_UUID:8 into mysql.gtid_executed table --let $assert_cond= "[SELECT COUNT(*) FROM mysql.gtid_executed WHERE interval_end = 8]" = 1 --source include/assert.inc # Check-10: REPAIR TABLE --echo # --echo # The REPAIR TABLE statement can be failed partially when repairing --echo # multiple tables, which contain a non-existent table. --echo # --replace_result $master_uuid MASTER_UUID --eval SET SESSION GTID_NEXT='$master_uuid:9' REPAIR TABLE t1, t_non_existent; --echo # --echo # When repairing a non-existent table, verify that the REPAIR TABLE --echo # statement saves its specified gtid into @@GLOBAL.GTID_EXECUTED and --echo # mysql.gtid_executed table when binlog is disabled as it did --echo # when binlog is enabled. --echo # --replace_result $master_uuid MASTER_UUID --let $assert_text= Committed gtid MASTER_UUID:9 into @@GLOBAL.GTID_EXECUTED --let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$master_uuid:1-9" --source include/assert.inc --eval SET SESSION GTID_NEXT='AUTOMATIC' FLUSH LOGS; --let $assert_text= Saved gtid MASTER_UUID:9 into mysql.gtid_executed table --let $assert_cond= "[SELECT COUNT(*) FROM mysql.gtid_executed WHERE interval_end = 9]" = 1 --source include/assert.inc # Check-11: CHECKSUM TABLE --echo # --echo # The CHECKSUM TABLE statement can be failed partially when checksuming --echo # multiple tables, which contain a non-existent table. --echo # --replace_result $master_uuid MASTER_UUID --eval SET SESSION GTID_NEXT='$master_uuid:10' CHECKSUM TABLE t1, t_non_existent; --echo # --echo # When checksuming a non-existent table, verify that the CHECKSUM TABLE --echo # statement does not save its specified gtid into @@GLOBAL.GTID_EXECUTED --echo # and mysql.gtid_executed table when binlog is disabled as it did --echo # when binlog is enabled. --echo # --replace_result $master_uuid MASTER_UUID --let $assert_text= Did not commit gtid MASTER_UUID:10 into @@GLOBAL.GTID_EXECUTED --let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$master_uuid:1-9" --source include/assert.inc --eval SET SESSION GTID_NEXT='AUTOMATIC' FLUSH LOGS; --let $assert_text= Did not save gtid MASTER_UUID:10 into mysql.gtid_executed table --let $assert_cond= "[SELECT COUNT(*) FROM mysql.gtid_executed WHERE interval_end = 10]" = 0 --source include/assert.inc # Check-12: RENAME USER --replace_result $master_uuid MASTER_UUID --eval SET SESSION GTID_NEXT='$master_uuid:11' --error ER_CANNOT_USER RENAME USER u1@h TO u11@h, u3@h TO u33@h; --echo # --echo # The u1 is not renamed on mysql.user which means that RENAME USER --echo # cannot be failed partially. --echo # SELECT user FROM mysql.user where user='u1'; --echo # --echo # Verify that the failed RENAME USER statement does not save --echo # the specified gtid into @@GLOBAL.GTID_EXECUTED and --echo # mysql.gtid_executed table. --echo # --replace_result $master_uuid MASTER_UUID --let $assert_text= Did not commit gtid MASTER_UUID:11 into @@GLOBAL.GTID_EXECUTED --let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$master_uuid:1-9" --source include/assert.inc --eval SET SESSION GTID_NEXT='AUTOMATIC' FLUSH LOGS; --let $assert_text= Did not save gtid MASTER_UUID:11 and :12 into mysql.gtid_executed table --let $assert_cond= "[SELECT COUNT(*) FROM mysql.gtid_executed WHERE interval_end = 11]" = 0 --source include/assert.inc # Check-14: ALTER USER SELECT password_expired FROM mysql.user where user='u1'; --replace_result $master_uuid MASTER_UUID --eval SET SESSION GTID_NEXT='$master_uuid:13' --error ER_CANNOT_USER ALTER USER u1@h, u3@h PASSWORD EXPIRE; --echo # --echo # The u1 is not altered on mysql.user which means that ALTER USER --echo # cannot be failed partially. --echo # SELECT password_expired FROM mysql.user where user='u1'; --echo # --echo # Verify that the failed ALTER USER statement does not save --echo # the specified gtid into @@GLOBAL.GTID_EXECUTED and --echo # mysql.gtid_executed table. --echo # --replace_result $master_uuid MASTER_UUID --let $assert_text= Did not commit gtid MASTER_UUID:13 into @@GLOBAL.GTID_EXECUTED --let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$master_uuid:1-9" --source include/assert.inc --eval SET SESSION GTID_NEXT='AUTOMATIC' FLUSH LOGS; --let $assert_text= Did not save gtid MASTER_UUID:13 into mysql.gtid_executed table --let $assert_cond= "[SELECT COUNT(*) FROM mysql.gtid_executed WHERE interval_end = 13]" = 0 --source include/assert.inc # Clean up --replace_result $master_uuid MASTER_UUID --eval SET SESSION GTID_NEXT='$master_uuid:14' DROP TABLE t1; --replace_result $master_uuid MASTER_UUID --eval SET SESSION GTID_NEXT='$master_uuid:15' DROP TABLE t5; --replace_result $master_uuid MASTER_UUID --eval SET SESSION GTID_NEXT='$master_uuid:16' DROP USER u1@h;