mirror of
https://github.com/MariaDB/server.git
synced 2025-10-22 07:44:04 +02:00

This is actually an existing problem in the old binlog implementation, and this patch is applicable to old binlog also. The problem is that RESET MASTER can run concurrently with binlog dump threads / connected slaves. This will remove the binlog from under the feet of the reader, which can cause all sorts of strange behaviour. This patch fixes the problem by disallowing to run RESET MASTER when dump threads (or other RESET MASTER or SHOW BINARY LOGS) are running. An error is thrown in this case, user must stop slaves and/or kill dump threads to make the RESET MASTER go through. A slave that connects in the middle of RESET MASTER will wait for it to complete. Fix a lot of test cases to kill any lingering dump threads before doing RESET MASTER, mostly just by sourcing include/kill_binlog_dump_threads.inc. Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
174 lines
6 KiB
Text
174 lines
6 KiB
Text
#
|
|
# Test two primary nodes async replication to Galera cluster
|
|
#
|
|
# primary1 primary2
|
|
# #3 #4
|
|
# | |
|
|
# | async replication v
|
|
# +-------------------+ +----------------+
|
|
# | |
|
|
# v v
|
|
# galera replica <------galera replication-------->galera node_2
|
|
# #1 #2
|
|
#
|
|
# Test outline
|
|
#
|
|
# - Create user for async replication and table with rows in both primaries
|
|
# - Verify that tables and rows are replicated to all Galera nodes
|
|
# - Verify that gtid position is same in all Galera nodes
|
|
#
|
|
# The galera/galera_2nodes_as_replica_2primary.cnf describes the setup of the nodes
|
|
#
|
|
--source include/force_restart.inc
|
|
--source include/galera_cluster.inc
|
|
--source include/have_innodb.inc
|
|
|
|
# As node #3 and #4 are not a Galera node, and galera_cluster.inc does not open connetion to it
|
|
# we open the connections here
|
|
--connect primary1, 127.0.0.1, root, , test, $NODE_MYPORT_3
|
|
--connect primary2, 127.0.0.1, root, , test, $NODE_MYPORT_4
|
|
--connection primary1
|
|
--echo # Primary1 creating user for replication
|
|
create user repl@'%' identified by 'repl';
|
|
grant all on *.* to repl@'%';
|
|
|
|
--connection primary2
|
|
--echo # Primary2 creating user for replication
|
|
create user repl2@'%' identified by 'repl2';
|
|
grant all on *.* to repl2@'%';
|
|
|
|
--connect replica, 127.0.0.1, root, , test, $NODE_MYPORT_1
|
|
|
|
--let $node_1 = replica
|
|
--let $node_2 = node_2
|
|
--let $node_3 = primary1
|
|
--let $node_4 = primary2
|
|
--source include/auto_increment_offset_save.inc
|
|
|
|
--connection replica
|
|
--echo # Galera replica changing master to primary1
|
|
SET @@default_master_connection='stream1';
|
|
--disable_query_log
|
|
--eval CHANGE MASTER 'stream1' TO master_host='127.0.0.1', master_user='repl', master_password='repl', master_ssl_verify_server_cert=0, master_port=$NODE_MYPORT_3, master_use_gtid=slave_pos;
|
|
--enable_query_log
|
|
|
|
--echo # Primary node changing master to primary2
|
|
SET @@default_master_connection='stream2';
|
|
--disable_query_log
|
|
--eval CHANGE MASTER 'stream2' TO master_host='127.0.0.1', master_user='repl2', master_password='repl2', master_ssl_verify_server_cert=0, master_port=$NODE_MYPORT_4, master_use_gtid=slave_pos;
|
|
--enable_query_log
|
|
|
|
START ALL SLAVES;
|
|
|
|
--connection primary1
|
|
--echo # Primary 1: Creating table and populating it with data
|
|
CREATE TABLE t1 (id bigint auto_increment primary key, msg varchar(100)) engine=innodb;
|
|
--disable_query_log
|
|
--echo # Intentionally generate 1k GTID-events
|
|
--let $inserts=1000
|
|
--let $count=0
|
|
--disable_query_log
|
|
while($count < $inserts)
|
|
{
|
|
--eval insert into t1 values (NULL,'test1')
|
|
--inc $count
|
|
}
|
|
--enable_query_log
|
|
|
|
SELECT COUNT(*) AS EXPECT_1000 FROM t1;
|
|
|
|
--connection primary2
|
|
--echo # Primary 2: Creating table and populating it with data
|
|
CREATE TABLE t2 (id bigint auto_increment primary key, msg varchar(100)) engine=innodb;
|
|
--echo # Intentionally generate 1k GTID-events
|
|
--let $inserts=1000
|
|
--let $count=0
|
|
--disable_query_log
|
|
while($count < $inserts)
|
|
{
|
|
--eval insert into t2 values (NULL,'test1')
|
|
--inc $count
|
|
}
|
|
--enable_query_log
|
|
|
|
SELECT COUNT(*) AS EXPECT_1000 FROM t2;
|
|
|
|
--connection replica
|
|
--echo # Waiting for data to replicate to node_1
|
|
--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
|
|
--let $wait_condition_on_error_output = SHOW ALL SLAVES STATUS;
|
|
--source include/wait_condition_with_debug.inc
|
|
--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't2';
|
|
--let $wait_condition_on_error_output = SHOW ALL SLAVES STATUS;
|
|
--source include/wait_condition_with_debug.inc
|
|
|
|
--let $wait_condition = SELECT COUNT(*) = 1000 FROM t1;
|
|
--source include/wait_condition.inc
|
|
--let $wait_condition = SELECT COUNT(*) = 1000 FROM t2;
|
|
--source include/wait_condition.inc
|
|
|
|
SELECT COUNT(*) AS EXPECT_1000 FROM t1;
|
|
SELECT COUNT(*) AS EXPECT_1000 FROM t2;
|
|
|
|
SELECT COUNT(*) > 0 AS EXPECT_1 FROM mysql.gtid_slave_pos;
|
|
SELECT COUNT(*) < 1000 AS EXPECT_1 FROM mysql.gtid_slave_pos;
|
|
SELECT @@gtid_slave_pos,@@gtid_binlog_pos,@@gtid_current_pos;
|
|
|
|
--connection node_2
|
|
--echo # Waiting for data to replicate to node_2
|
|
--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
|
|
--source include/wait_condition.inc
|
|
--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't2';
|
|
--source include/wait_condition.inc
|
|
|
|
--let $wait_condition = SELECT COUNT(*) = 1000 FROM t1;
|
|
--source include/wait_condition.inc
|
|
--let $wait_condition = SELECT COUNT(*) = 1000 FROM t2;
|
|
--source include/wait_condition.inc
|
|
|
|
SELECT COUNT(*) AS EXPECT_1000 FROM t1;
|
|
SELECT COUNT(*) AS EXPECT_1000 FROM t2;
|
|
SELECT COUNT(*) > 0 AS EXPECT_1 FROM mysql.gtid_slave_pos;
|
|
SELECT COUNT(*) < 1000 AS EXPECT_1 FROM mysql.gtid_slave_pos;
|
|
SELECT @@gtid_slave_pos,@@gtid_binlog_pos,@@gtid_current_pos;
|
|
#
|
|
# Cleanup
|
|
#
|
|
--connection primary1
|
|
drop table t1;
|
|
--connection primary2
|
|
drop table t2;
|
|
|
|
--echo # Wait until drop table is replicated on Galera
|
|
--connection replica
|
|
--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
|
|
--source include/wait_condition.inc
|
|
--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't2';
|
|
--source include/wait_condition.inc
|
|
|
|
--connection node_2
|
|
--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
|
|
--source include/wait_condition.inc
|
|
--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't2';
|
|
--source include/wait_condition.inc
|
|
|
|
--connection replica
|
|
STOP ALL SLAVES;
|
|
RESET SLAVE ALL;
|
|
|
|
--connection primary1
|
|
--source include/kill_binlog_dump_threads.inc
|
|
RESET MASTER;
|
|
--connection primary2
|
|
--source include/kill_binlog_dump_threads.inc
|
|
RESET MASTER;
|
|
|
|
--source include/auto_increment_offset_restore.inc
|
|
|
|
--connection node_1
|
|
--disconnect primary1
|
|
--disconnect primary2
|
|
--disconnect replica
|
|
|
|
--source include/galera_end.inc
|
|
--echo # End of test
|