mariadb/mysql-test/suite/rpl/r/rpl_stop_slave.result
Brandon Nesterenko 5ab5ff08b0 MDEV-19801: Change defaults for CHANGE MASTER TO so that GTID-based replication is used by default if master supports it
This commit makes replicas crash-safe by default by changing the
Using_Gtid value to be Slave_Pos on a fresh slave start and after
RESET SLAVE is issued. If the primary server does not support GTIDs
(i.e., version < 10), the replica will fall back to Using_Gtid=No on
slave start and after RESET SLAVE.

The following additional informational messages/warnings are added:

 1. When Using_Gtid is automatically changed. That is, if RESET
SLAVE reverts Using_Gtid back to Slave_Pos, or Using_Gtid is
inferred to No from a CHANGE MASTER TO given with log coordinates
without MASTER_USE_GTID.
 2. If options are ignored in CHANGE MASTER TO. If CHANGE MASTER TO
is given with log coordinates, yet also specifies
MASTER_USE_GTID=Slave_Pos, a warning message is given that the log
coordinate options are ignored.

Additionally, an MTR macro has been added for RESET SLAVE,
reset_slave.inc, which provides modes/options for resetting a slave
in log coordinate or gtid modes. When in log coordinates mode, the
macro will execute CHANGE MASTER TO MASTER_USE_GTID=No after the
RESET SLAVE command. When in GTID mode, an extra parameter,
reset_slave_keep_gtid_state, can be set to reset or preserve the
value of gtid_slave_pos.

Reviewed By:
===========
Andrei Elkin <andrei.elkin@mariadb.com>
2022-07-26 13:31:27 -06:00

138 lines
4.3 KiB
Text

include/master-slave.inc
[connection master]
connection slave;
include/stop_slave.inc
CHANGE MASTER TO MASTER_USE_GTID=NO;
include/start_slave.inc
connection master;
# BUG#56118 STOP SLAVE does not wait till trx with CREATE TMP TABLE ends
#
# If a temporary table is created or dropped, the transaction should be
# regarded similarly that a non-transactional table is modified. So
# STOP SLAVE should wait until the transaction has finished.
CREATE TABLE t1(c1 INT) ENGINE=InnoDB;
CREATE TABLE t2(c1 INT) ENGINE=InnoDB;
connection slave;
SET DEBUG_SYNC= 'RESET';
include/stop_slave.inc
# Suspend the INSERT statement in current transaction on SQL thread.
# It guarantees that SQL thread is applying the transaction when
# STOP SLAVE command launchs.
SET @saved_dbug = @@GLOBAL.debug_dbug;
set global debug_dbug= '+d,after_mysql_insert';
include/start_slave.inc
# CREATE TEMPORARY TABLE with InnoDB engine
# -----------------------------------------
connection master;
BEGIN;
DELETE FROM t1;
CREATE TEMPORARY TABLE tt1(c1 INT) ENGINE = InnoDB;
INSERT INTO t1 VALUES (1);
DROP TEMPORARY TABLE tt1;
COMMIT;
connection slave;
STOP SLAVE SQL_THREAD;
connection slave1;
# To resume slave SQL thread
SET DEBUG_SYNC= 'now SIGNAL signal.continue';
SET DEBUG_SYNC= 'now WAIT_FOR signal.continued';
SET DEBUG_SYNC= 'RESET';
connection slave;
include/wait_for_slave_sql_to_stop.inc
# Slave should stop after the transaction has committed.
# So t1 on master is same to t1 on slave.
include/diff_tables.inc [master:t1, slave:t1]
connection slave;
START SLAVE SQL_THREAD;
include/wait_for_slave_sql_to_start.inc
connection master;
connection slave;
# CREATE TEMPORARY TABLE ... SELECT with InnoDB engine
# ----------------------------------------------------
connection master;
BEGIN;
DELETE FROM t1;
CREATE TEMPORARY TABLE tt1(c1 INT) ENGINE = InnoDB
SELECT c1 FROM t2;
INSERT INTO t1 VALUES (1);
DROP TEMPORARY TABLE tt1;
COMMIT;
connection slave;
STOP SLAVE SQL_THREAD;
connection slave1;
# To resume slave SQL thread
SET DEBUG_SYNC= 'now SIGNAL signal.continue';
SET DEBUG_SYNC= 'now WAIT_FOR signal.continued';
SET DEBUG_SYNC= 'RESET';
connection slave;
include/wait_for_slave_sql_to_stop.inc
# Slave should stop after the transaction has committed.
# So t1 on master is same to t1 on slave.
include/diff_tables.inc [master:t1, slave:t1]
connection slave;
START SLAVE SQL_THREAD;
include/wait_for_slave_sql_to_start.inc
connection master;
connection slave;
# Test end
SET @@GLOBAL.debug_dbug = @saved_dbug;
include/restart_slave.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;
DROP TABLE t1, t2;
# Bug#58546 test rpl_packet timeout failure sporadically on PB
# ----------------------------------------------------------------------
# STOP SLAVE stopped IO thread first and then stopped SQL thread. It was
# possible that IO thread stopped after replicating part of a transaction
# which SQL thread was executing. SQL thread would be hung if the
# transaction could not be rolled back safely.
# It caused some sporadic failures on PB2.
#
# This test verifies that when 'STOP SLAVE' is issued by a user, IO
# thread will continue to fetch the rest events of the transaction which
# 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);
connection slave;
include/stop_slave.inc
connection master;
include/stop_dump_threads.inc
SET @saved_dbug = @@GLOBAL.debug_dbug;
set global debug_dbug= '+d,dump_thread_wait_before_send_xid';
connection slave;
include/start_slave.inc
BEGIN;
UPDATE t1 SET c2 = 2 WHERE c1 = 1;
connection master;
BEGIN;
INSERT INTO t1 VALUES(2, 2);
INSERT INTO t2 VALUES(1);
UPDATE t1 SET c2 = 3 WHERE c1 = 1;
COMMIT;
connection slave1;
STOP SLAVE;
connection slave;
ROLLBACK;
connection master;
SET DEBUG_SYNC= 'now SIGNAL signal.continue';
SET DEBUG_SYNC= 'now WAIT_FOR signal.continued';
connection slave;
include/wait_for_slave_to_stop.inc
connection slave1;
connection master;
SET @@GLOBAL.debug_dbug = @saved_dbug;
include/stop_dump_threads.inc
connection slave1;
include/start_slave.inc
connection master;
DROP TABLE t1, t2;
include/rpl_end.inc
SET DEBUG_SYNC= 'RESET';