| 1 |
############################################################################ |
| 2 |
# Bug #17650326 MYSQLBINLOG PRINTS INVALID SQL FROM RELAY LOGS WHEN GTID IS |
| 3 |
# ENABLED |
| 4 |
# Problem: Replaying a relaylog which ends with GTID_LOG_EVENT causes error |
| 5 |
# "ERROR 1790 (HY000) @@SESSION.GTID_NEXT cannot be changed by a client that |
| 6 |
# owns a GTID. The client owns <UUID:GNO>. Ownership is released on COMMIT |
| 7 |
# or ROLLBACK." |
| 8 |
# |
| 9 |
# Steps to reproduce: |
| 10 |
# 1) Stop IO thread after reading gtid_log_event (relaylog 1 contains |
| 11 |
# GTID_LOG_EVENT at the end) |
| 12 |
# 2) Restart IO thread which rotates relaylog file (relaylog 2) |
| 13 |
# 3) Replay relaylog1's 'mysqlbinlog' output against 'mysql' client tool, |
| 14 |
# it should not cause any problems. |
| 15 |
# 4) Replay (relaylog1 + relaylog2)'s 'mysqlbinlog' output against |
| 16 |
# 'mysql' client tool, it should not cause any problems. |
| 17 |
# |
| 18 |
############################################################################ |
| 19 |
--source include/have_debug.inc |
| 20 |
--source include/have_binlog_format_statement.inc |
| 21 |
--source include/master-slave.inc |
| 22 |
|
| 23 |
# Initial setup |
| 24 |
CREATE TABLE t1(i INT) ENGINE=InnoDB; |
| 25 |
INSERT INTO t1 VALUES (1); |
| 26 |
--source include/sync_slave_sql_with_master.inc |
| 27 |
--let MYSQLD_DATADIR=`select @@datadir` |
| 28 |
SET @save_debug=@@global.debug; |
| 29 |
|
| 30 |
# Step 1: Stop I/O thread after reading GTID_LOG_EVENT |
| 31 |
# This will leave the relaylog in incomplete state(i.e., it ends |
| 32 |
# with GTID_LOG_EVENT) |
| 33 |
SET GLOBAL DEBUG='+d,stop_io_after_reading_gtid_log_event'; |
| 34 |
|
| 35 |
--source include/rpl_connection_master.inc |
| 36 |
INSERT INTO t1 VALUES (2); |
| 37 |
|
| 38 |
--source include/rpl_connection_slave.inc |
| 39 |
--source include/wait_for_slave_io_to_stop.inc |
| 40 |
--let $relay_file1 = query_get_value( SHOW SLAVE STATUS, Relay_Log_File, 1 ) |
| 41 |
|
| 42 |
--let $auto_pos = query_get_value( SHOW SLAVE STATUS, Auto_Position, 1 ) |
| 43 |
--let $assert_text= Slave MASTER_AUTO_POSITION should be enabled for this test |
| 44 |
--let $assert_cond= $auto_pos= 1 |
| 45 |
--source include/assert.inc |
| 46 |
|
| 47 |
# Step 2: Restart I/O thread and execute the pending INSERT(2) |
| 48 |
SET GLOBAL DEBUG= @save_debug; |
| 49 |
--source include/start_slave.inc |
| 50 |
|
| 51 |
--source include/rpl_connection_master.inc |
| 52 |
--source include/sync_slave_sql_with_master.inc |
| 53 |
--let $relay_file2 = query_get_value( SHOW SLAVE STATUS, Relay_Log_File, 1 ) |
| 54 |
|
| 55 |
# Step 3: Replay the incomplete Relaylog's mysqlbinlog output against mysql and see that |
| 56 |
# there are no issues. |
| 57 |
DROP TABLE t1; |
| 58 |
RESET MASTER; |
| 59 |
--exec $MYSQL_BINLOG --force-if-open $MYSQLD_DATADIR/$relay_file1 | $MYSQL -uroot -S$SLAVE_MYSOCK -P$SLAVE_MYPORT |
| 60 |
|
| 61 |
--let $assert_text= Check that there is one tuple in the table |
| 62 |
--let $assert_cond= [SELECT COUNT(*) AS Val FROM t1 where i=1, Val, 1] = 1 |
| 63 |
--source include/assert.inc |
| 64 |
|
| 65 |
# Step 4: Concat two relay logs and then replay mysqlbinlog ouput against mysql and see |
| 66 |
# that there are no issues. |
| 67 |
DROP TABLE t1; |
| 68 |
RESET MASTER; |
| 69 |
--exec $MYSQL_BINLOG --force-if-open $MYSQLD_DATADIR/$relay_file1 $MYSQLD_DATADIR/$relay_file2 | $MYSQL -uroot -S$SLAVE_MYSOCK -P$SLAVE_MYPORT |
| 70 |
|
| 71 |
--let $assert_text= Check that there are two tuples in the table |
| 72 |
--let $assert_cond= [SELECT COUNT(*) AS Val FROM t1 where i=1 or i=2, Val, 1] = 2 |
| 73 |
--source include/assert.inc |
| 74 |
|
| 75 |
# Cleanup |
| 76 |
--source include/rpl_connection_master.inc |
| 77 |
DROP TABLE t1; |
| 78 |
--source include/rpl_end.inc |