mirror of
https://github.com/MariaDB/server.git
synced 2025-09-03 20:43:11 +03:00
The test case makes use of the fine DEBUG_SYNC facility. Furthermore, since it needs synchronization on internal threads (dump and SQL threads) the server code has DEBUG_SYNC commands internally deployed and activated through the DBUG_EXECUTE_IF macro. The internal DBUG_SYNC commands are then controlled from the test case through the DEBUG variable. There were three problems around the DEBUG + DEBUG_SYNC facility usage: 1. When signaling the SQL thread to continue, the test would reset immediately the DEBUG_SYNC variable. This could mean that the SQL thread might loose the signal and continue to wait forever; 2. A similar scenario was happening with the dump thread on the master. This thread was instructed to wait, and later it would be signaled to continue, but immediately after the DEBUG_SYNC would be reset. This could lead to the dump thread missing the signal and wait forever; 3. The test was not cleaning itself up with respect to the instrumentation of the dump thread. This would leave the conditional execution of an internal DEBUG_SYNC command active (through the usage of DBUG_EXECUTE_IF). We fix #1 and #2 by waiting for the threads to receive the signal and only then issue the reset. We fix #3 by reseting the DEBUG variable, thus deactivating the dump thread internal DEBUG_SYNC command.
145 lines
4.9 KiB
Plaintext
145 lines
4.9 KiB
Plaintext
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 ... 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;
|
|
|
|
# Don't need to verify 'CREATE TEMPORARY TABLE' with MyIASM engine, as it
|
|
# never is binlogged into a transaction since 5.5.
|
|
|
|
--echo
|
|
--echo # Test end
|
|
SET GLOBAL debug= '$debug_save';
|
|
source include/restart_slave_sql.inc;
|
|
|
|
connection slave;
|
|
call mtr.add_suppression("Slave SQL.*Request to stop slave SQL Thread received while applying a group that has non-transactional changes; waiting for completion of the group");
|
|
connection master;
|
|
|
|
--source include/rpl_connection_master.inc
|
|
DROP TABLE t1, t2;
|
|
|
|
--echo
|
|
--echo # Bug#58546 test rpl_packet timeout failure sporadically on PB
|
|
--echo # ----------------------------------------------------------------------
|
|
--echo # STOP SLAVE stopped IO thread first and then stopped SQL thread. It was
|
|
--echo # possible that IO thread stopped after replicating part of a transaction
|
|
--echo # which SQL thread was executing. SQL thread would be hung if the
|
|
--echo # transaction could not be rolled back safely.
|
|
--echo # It caused some sporadic failures on PB2.
|
|
--echo #
|
|
--echo # This test verifies that when 'STOP SLAVE' is issued by a user, IO
|
|
--echo # thread will continue to fetch the rest events of the transaction which
|
|
--echo # is being executed by SQL thread and is not able to be rolled back safely.
|
|
|
|
CREATE TABLE t1 (c1 INT KEY, c2 INT) ENGINE=InnoDB;
|
|
CREATE TABLE t2 (c1 INT) ENGINE=MyISAM;
|
|
INSERT INTO t1 VALUES(1, 1);
|
|
|
|
sync_slave_with_master;
|
|
--source include/stop_slave.inc
|
|
|
|
--source include/rpl_connection_master.inc
|
|
# make sure that there are no zombie threads
|
|
--source include/stop_dump_threads.inc
|
|
|
|
let $debug_save= `SELECT @@GLOBAL.debug`;
|
|
SET GLOBAL debug= 'd,dump_thread_wait_before_send_xid';
|
|
|
|
--source include/rpl_connection_slave.inc
|
|
--source include/start_slave.inc
|
|
|
|
BEGIN;
|
|
UPDATE t1 SET c2 = 2 WHERE c1 = 1;
|
|
|
|
--source include/rpl_connection_master.inc
|
|
BEGIN;
|
|
INSERT INTO t1 VALUES(2, 2);
|
|
INSERT INTO t2 VALUES(1);
|
|
UPDATE t1 SET c2 = 3 WHERE c1 = 1;
|
|
COMMIT;
|
|
|
|
# wait for the dump thread reach the sync point
|
|
--let $wait_condition= select count(*)=1 from information_schema.processlist where state LIKE '%debug sync point%' and command='Binlog Dump'
|
|
--source include/wait_condition.inc
|
|
|
|
--source include/rpl_connection_slave1.inc
|
|
let $show_statement= SHOW PROCESSLIST;
|
|
let $field= Info;
|
|
let $condition= = 'UPDATE t1 SET c2 = 3 WHERE c1 = 1';
|
|
source include/wait_show_condition.inc;
|
|
|
|
send STOP SLAVE;
|
|
|
|
--source include/rpl_connection_slave.inc
|
|
ROLLBACK;
|
|
|
|
--source include/rpl_connection_master.inc
|
|
|
|
SET DEBUG_SYNC= 'now SIGNAL signal.continue';
|
|
# wait for the dump thread to come out of the
|
|
# waiting phase before resetting the signals
|
|
--let $wait_condition= select count(*)=0 from information_schema.processlist where state LIKE '%debug sync point%' and command='Binlog Dump'
|
|
--source include/wait_condition.inc
|
|
SET DEBUG_SYNC= 'RESET';
|
|
|
|
--source include/rpl_connection_slave.inc
|
|
source include/wait_for_slave_to_stop.inc;
|
|
|
|
--source include/rpl_connection_slave1.inc
|
|
reap;
|
|
|
|
# Slave has stopped, thence lets make sure that
|
|
# we kill the zombie dump threads. Also, make
|
|
# sure that we disable the DBUG_EXECUTE_IF
|
|
# that would set the dump thread to wait
|
|
--source include/rpl_connection_master.inc
|
|
SET GLOBAL debug= '$debug_save';
|
|
# make sure that there are no zombie threads
|
|
--source include/stop_dump_threads.inc
|
|
|
|
--source include/rpl_connection_slave1.inc
|
|
# now the dump thread on the master will start
|
|
# from a clean slate, i.e. without the
|
|
# DBUG_EXECUTE_IF set
|
|
source include/start_slave.inc;
|
|
|
|
--source include/rpl_connection_master.inc
|
|
DROP TABLE t1, t2;
|
|
--source include/rpl_end.inc
|