mariadb/mysql-test/suite/rpl/t/rpl_stop_slave.test
unknown 211552ccee Bug#56118 STOP SLAVE does not wait till trx with CREATE TMP TABLE ends,
replication aborts

When recieving a 'SLAVE STOP' command, slave SQL thread will roll back the
transaction and stop immidiately if there is only transactional table updated,
even through 'CREATE|DROP TEMPOARY TABLE' statement are in it. But These
statements can never be rolled back. Because the temporary tables to the user
session mapping remain until 'RESET SLAVE', Therefore it will abort SQL thread
with an error that the table already exists or doesn't exist, when it restarts
and executes the whole transaction again.

After this patch, SQL thread always waits till the transaction ends and then stops,
if 'CREATE|DROP TEMPOARY TABLE' statement are in it.

mysql-test/extra/rpl_tests/rpl_stop_slave.test:
  Auxiliary file which is used to test this bug.
mysql-test/suite/rpl/t/rpl_stop_slave.test:
  Test case for this bug.
sql/slave.cc:
  Checking if OPTION_KEEP_LOG is set. If it is set, SQL thread should wait
  until the transaction ends.
sql/sql_parse.cc:
  Add a debug point for testing this bug.
2010-10-16 20:03:44 +08:00

60 lines
2.1 KiB
Text

source include/master-slave.inc;
source include/have_innodb.inc;
source include/have_debug.inc;
source include/have_debug_sync.inc;
source include/have_binlog_format_mixed_or_statement.inc;
--echo
--echo # BUG#56118 STOP SLAVE does not wait till trx with CREATE TMP TABLE ends
--echo #
--echo # If a temporary table is created or dropped, the transaction should be
--echo # regarded similarly that a non-transactional table is modified. So
--echo # STOP SLAVE should wait until the transaction has finished.
CREATE TABLE t1(c1 INT) ENGINE=InnoDB;
CREATE TABLE t2(c1 INT) ENGINE=InnoDB;
sync_slave_with_master;
SET DEBUG_SYNC= 'RESET';
source include/stop_slave.inc;
--echo
--echo # Suspend the INSERT statement in current transaction on SQL thread.
--echo # It guarantees that SQL thread is applying the transaction when
--echo # STOP SLAVE command launchs.
let $debug_save= `SELECT @@GLOBAL.debug`;
SET GLOBAL debug= 'd,after_mysql_insert';
source include/start_slave.inc;
--echo
--echo # CREATE TEMPORARY TABLE with InnoDB engine
--echo # -----------------------------------------
let $tmp_table_stm= CREATE TEMPORARY TABLE tt1(c1 INT) ENGINE = InnoDB;
source extra/rpl_tests/rpl_stop_slave.test;
--echo
--echo # CREATE TEMPORARY TABLE with MyISAM engine
--echo # -----------------------------------------
let $tmp_table_stm= CREATE TEMPORARY TABLE tt1(c1 INT) ENGINE = MyISAM;
source extra/rpl_tests/rpl_stop_slave.test;
--echo
--echo # CREATE TEMPORARY TABLE ... SELECT with InnoDB engine
--echo # ----------------------------------------------------
let $tmp_table_stm= CREATE TEMPORARY TABLE tt1(c1 INT) ENGINE = InnoDB
SELECT c1 FROM t2;
source extra/rpl_tests/rpl_stop_slave.test;
--echo
--echo # CREATE TEMPORARY TABLE ... SELECT with MyISAM engine
--echo # ----------------------------------------------------
let $tmp_table_stm= CREATE TEMPORARY TABLE tt1(c1 INT) ENGINE = MyISAM
SELECT 1 AS c1;
source extra/rpl_tests/rpl_stop_slave.test;
--echo # Test end
SET GLOBAL debug= '$debug_save';
connection master;
DROP TABLE t1, t2;
source include/master-slave-end.inc;