diff --git a/mysql-test/suite/binlog_encryption/encrypted_master_switch_to_unencrypted_gtid.result b/mysql-test/suite/binlog_encryption/encrypted_master_switch_to_unencrypted_gtid.result index d05e3abd068..be7c9b819ff 100644 --- a/mysql-test/suite/binlog_encryption/encrypted_master_switch_to_unencrypted_gtid.result +++ b/mysql-test/suite/binlog_encryption/encrypted_master_switch_to_unencrypted_gtid.result @@ -59,6 +59,9 @@ INSERT INTO table3_no_encryption SELECT NULL,NOW(),b FROM table3_no_encryption; connection server_2; start slave; include/wait_for_slave_io_error.inc [errno=1236] +SELECT MASTER_GTID_WAIT("LAST_UNENCRYPTED_GTID", 60); +MASTER_GTID_WAIT("LAST_UNENCRYPTED_GTID", 60) +0 # Ensuring slave was unable to replicate any encrypted transactions.. # ..success SHOW TABLES; diff --git a/mysql-test/suite/binlog_encryption/encrypted_master_switch_to_unencrypted_gtid.test b/mysql-test/suite/binlog_encryption/encrypted_master_switch_to_unencrypted_gtid.test index 7f717190cbf..f95262d99b2 100644 --- a/mysql-test/suite/binlog_encryption/encrypted_master_switch_to_unencrypted_gtid.test +++ b/mysql-test/suite/binlog_encryption/encrypted_master_switch_to_unencrypted_gtid.test @@ -122,6 +122,13 @@ start slave; --let $slave_io_errno= 1236 --source include/wait_for_slave_io_error.inc +# Wait for the SQL thread to have replicated to the expected point. Otherwise +# there is a race where the IO thread can stop with error and the test case +# check the @@GLOBAL.gtid_slave_pos before the SQL thread has had time to +# replicate the events queued by the IO thread (MDEV-36424). +--replace_result "$last_unencrypted_gtid" "LAST_UNENCRYPTED_GTID" +eval SELECT MASTER_GTID_WAIT("$last_unencrypted_gtid", 60); + --echo # Ensuring slave was unable to replicate any encrypted transactions.. --let $gsp= `SELECT @@global.gtid_slave_pos` if (`SELECT strcmp("$gsp","$last_unencrypted_gtid")`)