diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 12:24:36 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 12:24:36 +0000 |
commit | 06eaf7232e9a920468c0f8d74dcf2fe8b555501c (patch) | |
tree | e2c7b5777f728320e5b5542b6213fd3591ba51e2 /mysql-test/suite/galera/include | |
parent | Initial commit. (diff) | |
download | mariadb-06eaf7232e9a920468c0f8d74dcf2fe8b555501c.tar.xz mariadb-06eaf7232e9a920468c0f8d74dcf2fe8b555501c.zip |
Adding upstream version 1:10.11.6.upstream/1%10.11.6
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'mysql-test/suite/galera/include')
23 files changed, 1120 insertions, 0 deletions
diff --git a/mysql-test/suite/galera/include/auto_increment_offset_restore.inc b/mysql-test/suite/galera/include/auto_increment_offset_restore.inc new file mode 100644 index 00000000..1248ed10 --- /dev/null +++ b/mysql-test/suite/galera/include/auto_increment_offset_restore.inc @@ -0,0 +1,41 @@ +# See auto_increment_offset_restore.inc for details. + +if (!$node_1) +{ + --die ERROR IN TEST: $node_1 must be set before sourcing auto_increment_offset_save.inc +} + +if (!$node_2) +{ + --die ERROR IN TEST: $node_2 must be set before sourcing auto_increment_offset_save.inc +} + +if (!$auto_increment_offset_node_1) +{ + --die ERROR IN TEST: $auto_increment_offset_node_1 must be set before sourcing auto_increment_offset_save.inc +} + +if (!$auto_increment_offset_node_2) +{ + --die ERROR IN TEST: $auto_increment_offset_node_2 must be set before sourcing auto_increment_offset_save.inc +} + +# Restore original auto_increment_offset values. +--disable_query_log +--connection $node_1 +--eval SET @@global.auto_increment_offset = $auto_increment_offset_node_1; +--connection $node_2 +--eval SET @@global.auto_increment_offset = $auto_increment_offset_node_2; + +if ($node_3) +{ +--connection $node_3 +--eval SET @@global.auto_increment_offset = $auto_increment_offset_node_3; +} + +if ($node_4) +{ +--connection $node_4 +--eval SET @@global.auto_increment_offset = $auto_increment_offset_node_4; +} +--enable_query_log diff --git a/mysql-test/suite/galera/include/auto_increment_offset_save.inc b/mysql-test/suite/galera/include/auto_increment_offset_save.inc new file mode 100644 index 00000000..216c689e --- /dev/null +++ b/mysql-test/suite/galera/include/auto_increment_offset_save.inc @@ -0,0 +1,45 @@ +# This file can be used to save the @@global.auto_increment_offset value at +# the beginning of any test that intends to restart any of the participating +# nodes. This is required as the node may get auto-assigned a different +# auto_increment_offset value on restart, which could cause MTR's internal +# post-check to fail. auto_increment_offset_restore.inc can be used at the +# end of the test to restore these saved values. + +# Parameters +# ---------- +# $node_1 +# Connection handle for 1st node +# $node_2 +# Connection handle for 2nd node +# $node_3 (optional) +# Connection handle for 3rd node +# $node_4 (optional) +# Connection handle for 4th node + +if (!$node_1) +{ + --die ERROR IN TEST: $node_1 must be set before sourcing auto_increment_offset_save.inc +} + +if (!$node_2) +{ + --die ERROR IN TEST: $node_2 must be set before sourcing auto_increment_offset_save.inc +} + +--connection $node_1 +let $auto_increment_offset_node_1 = `SELECT @@global.auto_increment_offset`; +--connection $node_2 +let $auto_increment_offset_node_2 = `SELECT @@global.auto_increment_offset`; + +if ($node_3) +{ + --connection $node_3 + let $auto_increment_offset_node_3 = `SELECT @@global.auto_increment_offset`; +} + +if ($node_4) +{ + --connection $node_4 + let $auto_increment_offset_node_4 = `SELECT @@global.auto_increment_offset`; +} + diff --git a/mysql-test/suite/galera/include/galera_base_port.inc b/mysql-test/suite/galera/include/galera_base_port.inc new file mode 100644 index 00000000..caf986ee --- /dev/null +++ b/mysql-test/suite/galera/include/galera_base_port.inc @@ -0,0 +1,8 @@ +# +# Extract base_port from galera node. +# + +# Convert "... base_port = N; ..." to "N; ..." +--let $s1 = `SELECT SUBSTR(@@wsrep_provider_options, LOCATE('base_port =', @@wsrep_provider_options) + LENGTH('base_port = '))` +# Convert "N; ..." to "N" +--let $_NODE_GALERAPORT = `SELECT SUBSTR('$s1', 1, LOCATE(';', '$s1') - 1)` diff --git a/mysql-test/suite/galera/include/galera_concurrent_test.inc b/mysql-test/suite/galera/include/galera_concurrent_test.inc new file mode 100644 index 00000000..3d1bc767 --- /dev/null +++ b/mysql-test/suite/galera/include/galera_concurrent_test.inc @@ -0,0 +1,90 @@ +# +# Perform a quick concurrent test on two nodes using a set of predefined statements. +# +# Such tests are not deterministic, so we are hoping to catch assertions, slave apply errors +# and cases where the two nodes diverge +# +# Parameters: +# - $wsrep_trx_fragment_size +# - $count +# - $query_node_1 +# - $query_node_1a (optional) +# - $query_node_2 +# + +if (!$count) { + --let $count = 50; +} + +if (!$node_1a_connected) { + --connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1 + --let $node_1a_connected = 1 +} + +--echo Running a concurrent test with the following queries: +--echo $query_node_1 +--echo $query_node_1a +--echo $query_node_2 + +--connection node_1 +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY AUTO_INCREMENT, f2 CHAR(255)) ENGINE=InnoDB; + +SET SESSION wsrep_sync_wait = 0; +--eval SET SESSION wsrep_trx_fragment_size = $wsrep_trx_fragment_size; + +--connection node_1a +SET SESSION wsrep_sync_wait = 0; +--eval SET SESSION wsrep_trx_fragment_size = $wsrep_trx_fragment_size; + +--connection node_2 +SET SESSION wsrep_sync_wait = 0; +--eval SET SESSION wsrep_trx_fragment_size = $wsrep_trx_fragment_size; + +--disable_query_log +--let $i = `SELECT $count` +while ($i) +{ + --connection node_1 + --send_eval $query_node_1 + + --connection node_1a + if ($query_node_1a) { + --send_eval $query_node_1a + } + + --connection node_2 + --send_eval $query_node_2 + + --connection node_1 + --error 0,ER_QUERY_INTERRUPTED,ER_LOCK_DEADLOCK,ER_DUP_ENTRY + --reap + + --connection node_1a + if ($query_node_1a) { + --error 0,ER_QUERY_INTERRUPTED,ER_LOCK_DEADLOCK,ER_DUP_ENTRY + --reap + } + + --connection node_2 + --error 0,ER_QUERY_INTERRUPTED,ER_LOCK_DEADLOCK,ER_DUP_ENTRY + --reap + --dec $i +} + +SET SESSION wsrep_sync_wait = 15; +--enable_query_log + +--let $diff_servers = 1 2 +--source include/diff_servers.inc + +DROP TABLE t1; + +--let $query_node_1 = "" +--let $query_node_1a = "" +--let $query_node_2 = "" + +--echo Concurrent test end diff --git a/mysql-test/suite/galera/include/galera_dump_sr_table.inc b/mysql-test/suite/galera/include/galera_dump_sr_table.inc new file mode 100644 index 00000000..1e6ff554 --- /dev/null +++ b/mysql-test/suite/galera/include/galera_dump_sr_table.inc @@ -0,0 +1,28 @@ +# +# Dump the contents of the SR table using mysqldump +# + +--let $sr_min = `SELECT MIN(seqno) FROM mysql.wsrep_streaming_log` +--let $sr_max = `SELECT MAX(seqno) FROM mysql.wsrep_streaming_log` + +--let $seqno = $sr_min +while ($seqno <= $sr_max) +{ + --let $sr_fragment_file = $MYSQLTEST_VARDIR/tmp/sr_fragment.log + --exec rm -rf $sr_fragment_file + --disable_query_log + --eval SELECT frag INTO DUMPFILE '$sr_fragment_file' FROM mysql.wsrep_streaming_log WHERE seqno = $seqno + --enable_query_log + + --let $sr_binlog_file = $MYSQLTEST_VARDIR/tmp/sr_binlog.log + --exec rm -rf $sr_binlog_file + + --exec cp std_data/binlog-header.binlog $sr_binlog_file + --exec cat $sr_fragment_file >> $sr_binlog_file + + --replace_regex /SET TIMESTAMP=[0-9]+/SET TIMESTAMP=<TIMESTAMP>/ /#[0-9]+ +[0-9]+:[0-9]+:[0-9]+/<ISO TIMESTAMP>/ /pseudo_thread_id=[0-9]+/pseudo_thread_id=<PSEUDO_THREAD_ID>/ /thread_id=[0-9]+/thread_id=<QUERY_THREAD_ID>/ /table id [0-9]+/table id <TABLE_ID>/ /mapped to number [0-9]+/mapped to number <TABLE_ID>/ /auto_increment_increment=[0-9]+/auto_increment_increment=<AUTO_INCREMENT_INCREMENT>/ /auto_increment_offset=[0-9]+/auto_increment_offset=<AUTO_INCREMENT_OFFSET>/ /exec_time=[0-9]+/exec_time=<EXEC_TIME>/ + --exec $MYSQL_BINLOG $sr_binlog_file --base64-output=decode-rows --start-position=256 --skip-annotate-row-events | grep -v 'SET @' 2>&1 + + --inc $seqno +} + diff --git a/mysql-test/suite/galera/include/galera_reset_cluster_address.inc b/mysql-test/suite/galera/include/galera_reset_cluster_address.inc new file mode 100644 index 00000000..02937ec8 --- /dev/null +++ b/mysql-test/suite/galera/include/galera_reset_cluster_address.inc @@ -0,0 +1,12 @@ +--echo Resetting wsrep_cluster_address + +--let $wsrep_cluster_size_orig = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'` + +SET GLOBAL wsrep_cluster_address = @@wsrep_cluster_address; + +--source include/wait_until_connected_again.inc + +# Wait for wsrep_cluster_size to go back to its original value + +--let $wait_condition = SELECT VARIABLE_VALUE = $wsrep_cluster_size_orig FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' +--source include/wait_condition.inc diff --git a/mysql-test/suite/galera/include/galera_sst_restore.inc b/mysql-test/suite/galera/include/galera_sst_restore.inc new file mode 100644 index 00000000..3248c06c --- /dev/null +++ b/mysql-test/suite/galera/include/galera_sst_restore.inc @@ -0,0 +1,27 @@ +# +# Restore the various options used for SST to their original values +# so that MTR's end-of-test checks are happy. +# + +--connection node_1 +CALL mtr.add_suppression("Slave SQL: Error 'The MariaDB server is running with the --skip-grant-tables option so it cannot execute this statement' on query"); + +--disable_query_log +--eval SET GLOBAL wsrep_sst_auth = '$wsrep_sst_auth_orig'; +--enable_query_log + +--error 0,ER_CANNOT_USER +DROP USER sst; + +--connection node_2 +CALL mtr.add_suppression("Slave SQL: Error 'The MariaDB server is running with the --skip-grant-tables option so it cannot execute this statement' on query"); +CALL mtr.add_suppression("InnoDB: Error: Table \"mysql\"\\.\"innodb_index_stats\" not found"); +CALL mtr.add_suppression("Can't open and lock time zone table"); +CALL mtr.add_suppression("Can't open and lock privilege tables"); +CALL mtr.add_suppression("Info table is not ready to be used"); +CALL mtr.add_suppression("Native table .* has the wrong structure"); +CALL mtr.add_suppression("Table \'mysql.gtid_slave_pos\' doesn\'t exist"); +--disable_query_log +--eval SET GLOBAL wsrep_sst_method = '$wsrep_sst_method_orig'; +--eval SET GLOBAL wsrep_sst_receive_address = '$wsrep_sst_receive_address_orig'; +--enable_query_log diff --git a/mysql-test/suite/galera/include/galera_sst_set_mysqldump.inc b/mysql-test/suite/galera/include/galera_sst_set_mysqldump.inc new file mode 100644 index 00000000..16af5742 --- /dev/null +++ b/mysql-test/suite/galera/include/galera_sst_set_mysqldump.inc @@ -0,0 +1,27 @@ +# +# Set all the variables required for the SST to be performed via mysqldump +# + +--echo Setting SST method to mysqldump ... + +call mtr.add_suppression("WSREP: wsrep_sst_method is set to 'mysqldump' yet mysqld bind_address is set to '127.0.0.1'"); +call mtr.add_suppression("Failed to load slave replication state from table mysql.gtid_slave_pos"); + +--connection node_1 +# We need a user with a password to perform SST, otherwise we hit LP #1378253 +CREATE USER 'sst'; +GRANT ALL PRIVILEGES ON *.* TO 'sst'; + +--let $wsrep_sst_auth_orig = `SELECT @@wsrep_sst_auth` +SET GLOBAL wsrep_sst_auth = 'sst:'; + +--connection node_2 +--source include/wait_until_connected_again.inc +--let $wsrep_sst_method_orig = `SELECT @@wsrep_sst_method` +--let $wsrep_sst_receive_address_orig = `SELECT @@wsrep_sst_receive_address` + +--disable_query_log +# Set wsrep_sst_receive_address to the SQL port +--eval SET GLOBAL wsrep_sst_receive_address = '127.0.0.1:$NODE_MYPORT_2'; +--enable_query_log +SET GLOBAL wsrep_sst_method = 'mysqldump'; diff --git a/mysql-test/suite/galera/include/galera_st_clean_slave.inc b/mysql-test/suite/galera/include/galera_st_clean_slave.inc new file mode 100644 index 00000000..de1842e7 --- /dev/null +++ b/mysql-test/suite/galera/include/galera_st_clean_slave.inc @@ -0,0 +1,127 @@ +--echo Performing State Transfer on a server that starts from a clean var directory +--echo This is accomplished by shutting down node #2 and removing its var directory before restarting it + +--connection node_1 +CREATE TABLE t1 (id int not null primary key,f1 CHAR(255)) ENGINE=InnoDB; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (1,'node1_committed_before'); +INSERT INTO t1 VALUES (2,'node1_committed_before'); +INSERT INTO t1 VALUES (3,'node1_committed_before'); +INSERT INTO t1 VALUES (4,'node1_committed_before'); +INSERT INTO t1 VALUES (5,'node1_committed_before'); +COMMIT; + +--connection node_2 +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE 'test/t1'; +--source include/wait_condition.inc +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (6,'node2_committed_before'); +INSERT INTO t1 VALUES (7,'node2_committed_before'); +INSERT INTO t1 VALUES (8,'node2_committed_before'); +INSERT INTO t1 VALUES (9,'node2_committed_before'); +INSERT INTO t1 VALUES (10,'node2_committed_before'); +COMMIT; + +--echo Shutting down server ... +--source include/shutdown_mysqld.inc + +--connection node_1 +--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' +--source include/wait_condition.inc + +--echo Cleaning var directory ... +--remove_files_wildcard $MYSQLTEST_VARDIR/mysqld.2/data/mtr +--remove_files_wildcard $MYSQLTEST_VARDIR/mysqld.2/data/performance_schema +--remove_files_wildcard $MYSQLTEST_VARDIR/mysqld.2/data/test +--remove_files_wildcard $MYSQLTEST_VARDIR/mysqld.2/data/mysql +--remove_files_wildcard $MYSQLTEST_VARDIR/mysqld.2/data + +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (11,'node1_committed_during'); +INSERT INTO t1 VALUES (12,'node1_committed_during'); +INSERT INTO t1 VALUES (13,'node1_committed_during'); +INSERT INTO t1 VALUES (14,'node1_committed_during'); +INSERT INTO t1 VALUES (15,'node1_committed_during'); +COMMIT; + +START TRANSACTION; +INSERT INTO t1 VALUES (16,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (17,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (18,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (19,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (20,'node1_to_be_committed_after'); + +--connect node_1a_galera_st_clean_slave, 127.0.0.1, root, , test, $NODE_MYPORT_1 +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (21,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (22,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (23,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (24,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (25,'node1_to_be_rollbacked_after'); + +--connection node_2 +--echo Starting server ... +--source include/start_mysqld.inc + +--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' +--source include/wait_condition.inc + +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (26,'node2_committed_after'); +INSERT INTO t1 VALUES (27,'node2_committed_after'); +INSERT INTO t1 VALUES (28,'node2_committed_after'); +INSERT INTO t1 VALUES (29,'node2_committed_after'); +INSERT INTO t1 VALUES (30,'node2_committed_after'); +COMMIT; + +--connection node_1 +INSERT INTO t1 VALUES (31,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (32,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (33,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (34,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (35,'node1_to_be_committed_after'); +COMMIT; + +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (36,'node1_committed_after'); +INSERT INTO t1 VALUES (37,'node1_committed_after'); +INSERT INTO t1 VALUES (38,'node1_committed_after'); +INSERT INTO t1 VALUES (39,'node1_committed_after'); +INSERT INTO t1 VALUES (40,'node1_committed_after'); +COMMIT; + +--connection node_1a_galera_st_clean_slave +INSERT INTO t1 VALUES (41,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (42,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (43,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (44,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (45,'node1_to_be_rollbacked_after'); +ROLLBACK; + +--let $wait_condition = SELECT COUNT(*)=35 FROM t1 +--source include/wait_condition.inc + +SET AUTOCOMMIT=ON; +SET SESSION wsrep_sync_wait=15; +SELECT COUNT(*) AS EXPECT_35 FROM t1; +SELECT * from t1; +SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; +COMMIT; + +--connection node_1 +--let $wait_condition = SELECT COUNT(*)=35 FROM t1 +--source include/wait_condition.inc + +SET AUTOCOMMIT=ON; +SET SESSION wsrep_sync_wait=15; +SELECT COUNT(*) AS EXPECT_35 FROM t1; +SELECT * from t1; +SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; +DROP TABLE t1; +COMMIT; diff --git a/mysql-test/suite/galera/include/galera_st_disconnect_slave.inc b/mysql-test/suite/galera/include/galera_st_disconnect_slave.inc new file mode 100644 index 00000000..ecbd4bad --- /dev/null +++ b/mysql-test/suite/galera/include/galera_st_disconnect_slave.inc @@ -0,0 +1,122 @@ +--echo Performing State Transfer on a server that has been temporarily disconnected + +--connection node_1 +CREATE TABLE t1 (id int not null primary key,f1 CHAR(255)) ENGINE=InnoDB; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (1,'node1_committed_before'); +INSERT INTO t1 VALUES (2,'node1_committed_before'); +INSERT INTO t1 VALUES (3,'node1_committed_before'); +INSERT INTO t1 VALUES (4,'node1_committed_before'); +INSERT INTO t1 VALUES (5,'node1_committed_before'); +COMMIT; + +--connection node_2 +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (6,'node2_committed_before'); +INSERT INTO t1 VALUES (7,'node2_committed_before'); +INSERT INTO t1 VALUES (8,'node2_committed_before'); +INSERT INTO t1 VALUES (9,'node2_committed_before'); +INSERT INTO t1 VALUES (10,'node2_committed_before'); +COMMIT; + +--source suite/galera/include/galera_stop_replication.inc + +--connection node_1 +--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' +--source include/wait_condition.inc + +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (11,'node1_committed_during'); +INSERT INTO t1 VALUES (12,'node1_committed_during'); +INSERT INTO t1 VALUES (13,'node1_committed_during'); +INSERT INTO t1 VALUES (14,'node1_committed_during'); +INSERT INTO t1 VALUES (15,'node1_committed_during'); +COMMIT; + +START TRANSACTION; +INSERT INTO t1 VALUES (16,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (17,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (18,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (19,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (20,'node1_to_be_committed_after'); + +--connect node_1a_galera_st_disconnect_slave, 127.0.0.1, root, , test, $NODE_MYPORT_1 +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (21,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (22,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (23,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (24,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (25,'node1_to_be_rollbacked_after'); + +--connection node_2 +--source suite/galera/include/galera_start_replication.inc + +# +# client connections were killed by provider load, so have to re-open here +# +--disconnect node_2 +--connect node_2, 127.0.0.1, root, , test, $NODE_MYPORT_2 +--connection node_2 +--enable_reconnect + +--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' +--source include/wait_condition.inc + +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (26,'node2_committed_after'); +INSERT INTO t1 VALUES (27,'node2_committed_after'); +INSERT INTO t1 VALUES (28,'node2_committed_after'); +INSERT INTO t1 VALUES (29,'node2_committed_after'); +INSERT INTO t1 VALUES (30,'node2_committed_after'); +COMMIT; + +--connection node_1 +INSERT INTO t1 VALUES (31,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (32,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (33,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (34,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (35,'node1_to_be_committed_after'); +COMMIT; + +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (36,'node1_committed_after'); +INSERT INTO t1 VALUES (37,'node1_committed_after'); +INSERT INTO t1 VALUES (38,'node1_committed_after'); +INSERT INTO t1 VALUES (39,'node1_committed_after'); +INSERT INTO t1 VALUES (40,'node1_committed_after'); +COMMIT; + +--connection node_1a_galera_st_disconnect_slave +INSERT INTO t1 VALUES (41,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (42,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (43,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (44,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (45,'node1_to_be_rollbacked_after'); +ROLLBACK; + +--let $wait_condition = SELECT COUNT(*)=35 FROM t1 +--source include/wait_condition.inc + +SET AUTOCOMMIT=ON; +SET SESSION wsrep_sync_wait=15; +SELECT COUNT(*) AS EXPECT_35 FROM t1; +SELECT * FROM t1; +SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; + +--connection node_1 +--let $wait_condition = SELECT COUNT(*)=35 FROM t1 +--source include/wait_condition.inc + +SET AUTOCOMMIT=ON; +SET SESSION wsrep_sync_wait=15; +SELECT COUNT(*) AS EXPECT_35 FROM t1; +SELECT * FROM t1; +SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; +DROP TABLE t1; +COMMIT; diff --git a/mysql-test/suite/galera/include/galera_st_kill_slave.inc b/mysql-test/suite/galera/include/galera_st_kill_slave.inc new file mode 100644 index 00000000..c69dc1d7 --- /dev/null +++ b/mysql-test/suite/galera/include/galera_st_kill_slave.inc @@ -0,0 +1,121 @@ +--echo Performing State Transfer on a server that has been killed and restarted + +--connection node_1 +CREATE TABLE t1 (id int not null primary key,f1 CHAR(255)) ENGINE=InnoDB; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (1,'node1_committed_before'); +INSERT INTO t1 VALUES (2,'node1_committed_before'); +INSERT INTO t1 VALUES (3,'node1_committed_before'); +INSERT INTO t1 VALUES (4,'node1_committed_before'); +INSERT INTO t1 VALUES (5,'node1_committed_before'); +COMMIT; + +--connection node_2 +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE 'test/t1'; +--source include/wait_condition.inc +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (6,'node2_committed_before'); +INSERT INTO t1 VALUES (7,'node2_committed_before'); +INSERT INTO t1 VALUES (8,'node2_committed_before'); +INSERT INTO t1 VALUES (9,'node2_committed_before'); +INSERT INTO t1 VALUES (10,'node2_committed_before'); +COMMIT; + +--source include/kill_galera.inc + +--connection node_1 +--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' +--source include/wait_condition.inc + +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (11,'node1_committed_during'); +INSERT INTO t1 VALUES (12,'node1_committed_during'); +INSERT INTO t1 VALUES (13,'node1_committed_during'); +INSERT INTO t1 VALUES (14,'node1_committed_during'); +INSERT INTO t1 VALUES (15,'node1_committed_during'); +COMMIT; + +START TRANSACTION; +INSERT INTO t1 VALUES (16,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (17,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (18,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (19,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (20,'node1_to_be_committed_after'); + +--connect node_1a_galera_st_kill_slave, 127.0.0.1, root, , test, $NODE_MYPORT_1 +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (21,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (22,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (23,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (24,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (25,'node1_to_be_rollbacked_after'); + +--connection node_2 +--let $galera_wsrep_recover_server_id=2 +--source suite/galera/include/galera_wsrep_recover.inc + +--echo Starting server ... +--source include/start_mysqld.inc + +--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' +--source include/wait_condition.inc + +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (26,'node2_committed_after'); +INSERT INTO t1 VALUES (27,'node2_committed_after'); +INSERT INTO t1 VALUES (28,'node2_committed_after'); +INSERT INTO t1 VALUES (29,'node2_committed_after'); +INSERT INTO t1 VALUES (30,'node2_committed_after'); +COMMIT; + +--connection node_1 +INSERT INTO t1 VALUES (31,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (32,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (33,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (34,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (35,'node1_to_be_committed_after'); +COMMIT; + +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (36,'node1_committed_after'); +INSERT INTO t1 VALUES (37,'node1_committed_after'); +INSERT INTO t1 VALUES (38,'node1_committed_after'); +INSERT INTO t1 VALUES (39,'node1_committed_after'); +INSERT INTO t1 VALUES (40,'node1_committed_after'); +COMMIT; + +--connection node_1a_galera_st_kill_slave +INSERT INTO t1 VALUES (41,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (42,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (43,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (45,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (46,'node1_to_be_rollbacked_after'); +ROLLBACK; + +--let $wait_condition = SELECT COUNT(*)=35 FROM t1 +--source include/wait_condition.inc + +SET AUTOCOMMIT=ON; +SET SESSION wsrep_sync_wait=15; +SELECT COUNT(*) AS EXPECT_35 FROM t1; +SELECT * FROM t1; +SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; +COMMIT; + +--connection node_1 +--let $wait_condition = SELECT COUNT(*)=35 FROM t1 +--source include/wait_condition.inc + +SET AUTOCOMMIT=ON; +SET SESSION wsrep_sync_wait=15; +SELECT COUNT(*) AS EXPECT_35 FROM t1; +SELECT * FROM t1; +SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; +DROP TABLE t1; +COMMIT; diff --git a/mysql-test/suite/galera/include/galera_st_kill_slave_ddl.inc b/mysql-test/suite/galera/include/galera_st_kill_slave_ddl.inc new file mode 100644 index 00000000..22aa4f12 --- /dev/null +++ b/mysql-test/suite/galera/include/galera_st_kill_slave_ddl.inc @@ -0,0 +1,143 @@ +source include/maybe_debug.inc; +if ($have_debug) { +--echo Performing State Transfer on a server that has been killed and restarted +--echo while a DDL was in progress on it + +--connection node_1 +CREATE TABLE t1 (id int not null primary key,f1 CHAR(255)) ENGINE=InnoDB; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (1,'node1_committed_before'); +INSERT INTO t1 VALUES (2,'node1_committed_before'); +INSERT INTO t1 VALUES (3,'node1_committed_before'); +INSERT INTO t1 VALUES (4,'node1_committed_before'); +INSERT INTO t1 VALUES (5,'node1_committed_before'); + +--connection node_2 +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE 'test/t1'; +--source include/wait_condition.inc +START TRANSACTION; +INSERT INTO t1 VALUES (6,'node2_committed_before'); +INSERT INTO t1 VALUES (7,'node2_committed_before'); +INSERT INTO t1 VALUES (8,'node2_committed_before'); +INSERT INTO t1 VALUES (9,'node2_committed_before'); +INSERT INTO t1 VALUES (10,'node2_committed_before'); +COMMIT; + +# Suspend the applier as it applies the ALTER TABLE +--let $debug_orig = `SELECT @@debug_dbug` +SET GLOBAL debug_dbug = 'd,sync.alter_opened_table'; + +--connection node_1 +ALTER TABLE t1 ADD COLUMN f2 INTEGER; + +--connection node_2 +SET wsrep_sync_wait = 0; +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = 'debug sync point: now' +--source include/wait_condition.inc + +--source include/kill_galera.inc + +--connection node_1 +--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' +--source include/wait_condition.inc + +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 (id,f1) VALUES (11,'node1_committed_during'); +INSERT INTO t1 (id,f1) VALUES (12,'node1_committed_during'); +INSERT INTO t1 (id,f1) VALUES (13,'node1_committed_during'); +INSERT INTO t1 (id,f1) VALUES (14,'node1_committed_during'); +INSERT INTO t1 (id,f1) VALUES (15,'node1_committed_during'); +COMMIT; + +START TRANSACTION; +INSERT INTO t1 (id,f1) VALUES (16,'node1_to_be_committed_after'); +INSERT INTO t1 (id,f1) VALUES (17,'node1_to_be_committed_after'); +INSERT INTO t1 (id,f1) VALUES (18,'node1_to_be_committed_after'); +INSERT INTO t1 (id,f1) VALUES (19,'node1_to_be_committed_after'); +INSERT INTO t1 (id,f1) VALUES (20,'node1_to_be_committed_after'); + +--connect node_1a_galera_st_kill_slave_ddl, 127.0.0.1, root, , test, $NODE_MYPORT_1 +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 (id,f1) VALUES (21,'node1_to_be_rollbacked_after'); +INSERT INTO t1 (id,f1) VALUES (22,'node1_to_be_rollbacked_after'); +INSERT INTO t1 (id,f1) VALUES (23,'node1_to_be_rollbacked_after'); +INSERT INTO t1 (id,f1) VALUES (24,'node1_to_be_rollbacked_after'); +INSERT INTO t1 (id,f1) VALUES (25,'node1_to_be_rollbacked_after'); + +--connection node_2 +--let $galera_wsrep_recover_server_id=2 +--source suite/galera/include/galera_wsrep_recover.inc + +--connection node_2 +--echo Starting server ... +--source include/start_mysqld.inc + +--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' +--source include/wait_condition.inc + +--let $wait_condition = SELECT COUNT(*) = 3 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; +--source include/wait_condition.inc + +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 (id,f1) VALUES (26,'node2_committed_after'); +INSERT INTO t1 (id,f1) VALUES (27,'node2_committed_after'); +INSERT INTO t1 (id,f1) VALUES (28,'node2_committed_after'); +INSERT INTO t1 (id,f1) VALUES (29,'node2_committed_after'); +INSERT INTO t1 (id,f1) VALUES (30,'node2_committed_after'); +COMMIT; + +--connection node_1 +INSERT INTO t1 (id,f1) VALUES (31,'node1_to_be_committed_after'); +INSERT INTO t1 (id,f1) VALUES (32,'node1_to_be_committed_after'); +INSERT INTO t1 (id,f1) VALUES (33,'node1_to_be_committed_after'); +INSERT INTO t1 (id,f1) VALUES (34,'node1_to_be_committed_after'); +INSERT INTO t1 (id,f1) VALUES (35,'node1_to_be_committed_after'); +COMMIT; + +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 (id,f1) VALUES (36,'node1_committed_after'); +INSERT INTO t1 (id,f1) VALUES (37,'node1_committed_after'); +INSERT INTO t1 (id,f1) VALUES (38,'node1_committed_after'); +INSERT INTO t1 (id,f1) VALUES (39,'node1_committed_after'); +INSERT INTO t1 (id,f1) VALUES (40,'node1_committed_after'); +COMMIT; + +--connection node_1a_galera_st_kill_slave_ddl +INSERT INTO t1 (id,f1) VALUES (41,'node1_to_be_rollbacked_after'); +INSERT INTO t1 (id,f1) VALUES (42,'node1_to_be_rollbacked_after'); +INSERT INTO t1 (id,f1) VALUES (43,'node1_to_be_rollbacked_after'); +INSERT INTO t1 (id,f1) VALUES (44,'node1_to_be_rollbacked_after'); +INSERT INTO t1 (id,f1) VALUES (45,'node1_to_be_rollbacked_after'); +ROLLBACK; + +--let $wait_condition = SELECT COUNT(*)=35 FROM t1 +--source include/wait_condition.inc + +SET AUTOCOMMIT=ON; +SET SESSION wsrep_sync_wait=15; +SELECT COUNT(*) AS EXPECT_3 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; +SELECT COUNT(*) AS EXPECT_35 FROM t1; +SELECT * FROM t1; +SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; +COMMIT; + +--connection node_1 +--let $wait_condition = SELECT COUNT(*)=35 FROM t1 +--source include/wait_condition.inc + +SET AUTOCOMMIT=ON; +SET SESSION wsrep_sync_wait=15; +SELECT COUNT(*) AS EXPECT_3 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; +SELECT COUNT(*) AS EXPECT_35 FROM t1; +SELECT * FROM t1; +SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; +DROP TABLE t1; +COMMIT; + +SET GLOBAL debug_dbug = $debug_orig; +} diff --git a/mysql-test/suite/galera/include/galera_st_shutdown_slave.inc b/mysql-test/suite/galera/include/galera_st_shutdown_slave.inc new file mode 100644 index 00000000..7492e9f3 --- /dev/null +++ b/mysql-test/suite/galera/include/galera_st_shutdown_slave.inc @@ -0,0 +1,121 @@ +--echo Performing State Transfer on a server that has been shut down cleanly and restarted + +--connection node_1 +CREATE TABLE t1 (id int not null primary key,f1 CHAR(255)) ENGINE=InnoDB; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (1,'node1_committed_before'); +INSERT INTO t1 VALUES (2,'node1_committed_before'); +INSERT INTO t1 VALUES (3,'node1_committed_before'); +INSERT INTO t1 VALUES (4,'node1_committed_before'); +INSERT INTO t1 VALUES (5,'node1_committed_before'); +COMMIT; + +--connection node_2 +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE 'test/t1'; +--source include/wait_condition.inc + +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (6,'node2_committed_before'); +INSERT INTO t1 VALUES (7,'node2_committed_before'); +INSERT INTO t1 VALUES (8,'node2_committed_before'); +INSERT INTO t1 VALUES (9,'node2_committed_before'); +INSERT INTO t1 VALUES (10,'node2_committed_before'); +COMMIT; + +--echo Shutting down server ... +--source include/shutdown_mysqld.inc + +--connection node_1 +--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' +--source include/wait_condition.inc + +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (11,'node1_committed_during'); +INSERT INTO t1 VALUES (12,'node1_committed_during'); +INSERT INTO t1 VALUES (13,'node1_committed_during'); +INSERT INTO t1 VALUES (14,'node1_committed_during'); +INSERT INTO t1 VALUES (15,'node1_committed_during'); +COMMIT; + +START TRANSACTION; +INSERT INTO t1 VALUES (16,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (17,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (18,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (19,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (20,'node1_to_be_committed_after'); + +--connect node_1a_galera_st_shutdown_slave, 127.0.0.1, root, , test, $NODE_MYPORT_1 +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (21,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (22,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (23,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (24,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (25,'node1_to_be_rollbacked_after'); + +--connection node_2 +--echo Starting server ... +--source include/start_mysqld.inc + +--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' +--source include/wait_condition.inc + +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (26,'node2_committed_after'); +INSERT INTO t1 VALUES (27,'node2_committed_after'); +INSERT INTO t1 VALUES (28,'node2_committed_after'); +INSERT INTO t1 VALUES (29,'node2_committed_after'); +INSERT INTO t1 VALUES (30,'node2_committed_after'); +COMMIT; + +--connection node_1 +INSERT INTO t1 VALUES (31,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (32,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (33,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (34,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (35,'node1_to_be_committed_after'); +COMMIT; + +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (36,'node1_committed_after'); +INSERT INTO t1 VALUES (37,'node1_committed_after'); +INSERT INTO t1 VALUES (38,'node1_committed_after'); +INSERT INTO t1 VALUES (39,'node1_committed_after'); +INSERT INTO t1 VALUES (40,'node1_committed_after'); +COMMIT; + +--connection node_1a_galera_st_shutdown_slave +INSERT INTO t1 VALUES (41,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (42,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (43,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (44,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (45,'node1_to_be_rollbacked_after'); +ROLLBACK; + +--let $wait_condition = SELECT COUNT(*)=35 FROM t1 +--source include/wait_condition.inc + +SET AUTOCOMMIT=ON; +SET SESSION wsrep_sync_wait=15; +SELECT COUNT(*) AS EXPECT_15 FROM t1; +SELECT * from t1; +SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; +COMMIT; + +--connection node_1 +--let $wait_condition = SELECT COUNT(*)=35 FROM t1 +--source include/wait_condition.inc + +SET AUTOCOMMIT=ON; +SET SESSION wsrep_sync_wait=15; +SELECT COUNT(*) AS EXPECT_15 FROM t1; +SELECT * from t1; +SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; +DROP TABLE t1; +COMMIT; + diff --git a/mysql-test/suite/galera/include/galera_start_replication.inc b/mysql-test/suite/galera/include/galera_start_replication.inc new file mode 100644 index 00000000..b9b20110 --- /dev/null +++ b/mysql-test/suite/galera/include/galera_start_replication.inc @@ -0,0 +1,74 @@ +--echo Loading wsrep provider ... + +--disable_query_log +# +# count occurences of successful node starts in error log +# +perl; + use strict; + my $test_log=$ENV{'LOG_FILE'} or die "LOG_FILE not set"; + my $test_log_copy=$test_log . '.copy'; + if (-e $test_log_copy) { + unlink $test_log_copy; + } + +EOF +--copy_file $LOG_FILE $LOG_FILE.copy + +# +# now join to the cluster +# +--eval SET GLOBAL wsrep_cluster_address = '$wsrep_cluster_address_orig'; + +--enable_query_log + +# +# Cluster address change above, will launch SST/IST +# if mysqldump ST has been configured, mysqld will close all +# client connections, and it will be hard for us to poll for +# cluster status during SST process, therefore wait_until_connected_again.inc +# and wait_until_ready.inc may fail in this phase +# To workaround this, we do first lazy polling here just to see when +# client connections will be possible, and after that check for node readyness +# +--disable_result_log +--disable_query_log + +--error 0,1 +perl; + use strict; + my $logfile = $ENV{'LOG_FILE'} or die ("no error log file set"); + + my $counter = 1000; + #my $found = false + + while ($counter > 0) { + + open(FILE, "$logfile") or die("Unable to open $logfile : $!\n"); + my $new_sync_count = () = grep(/Synchronized with group/g,<FILE>); + close(FILE); + + open(FILEN, "$logfile.copy") or die("Unable to open $logfile.copy : $!\n"); + my $old_sync_count = () = grep(/Synchronized with group/g,<FILEN>); + close(FILEN); + + if ($new_sync_count > $old_sync_count ) { + exit(0); + } + $counter--; + sleep(5); + } + exit(1); +EOF +if ($errno) +{ +--echo "SST failed $errno" +} + +--remove_file $LOG_FILE.copy + +--enable_query_log +--enable_result_log +#--eval SET GLOBAL log_error = $log_error_; + +--source include/galera_wait_ready.inc diff --git a/mysql-test/suite/galera/include/galera_stop_replication.inc b/mysql-test/suite/galera/include/galera_stop_replication.inc new file mode 100644 index 00000000..ed7e9bc4 --- /dev/null +++ b/mysql-test/suite/galera/include/galera_stop_replication.inc @@ -0,0 +1,14 @@ +--echo Unloading wsrep provider ... + +--let $wsrep_cluster_address_orig = `SELECT @@wsrep_cluster_address` +--let $wsrep_provider_options_orig = `SELECT @@wsrep_provider_options` +--let $wsrep_error_log_orig = `SELECT @@log_error` +if(!$wsrep_log_error_orig) +{ + # MySQL Server on windows is started with --console and thus + # does not know the location of its .err log, use default location + let $wsrep_log_error_orig = $MYSQLTEST_VARDIR/log/mysqld.2.err; +} +--let LOG_FILE= $wsrep_log_error_orig + +SET GLOBAL wsrep_cluster_address = ''; diff --git a/mysql-test/suite/galera/include/galera_wsrep_recover.inc b/mysql-test/suite/galera/include/galera_wsrep_recover.inc new file mode 100644 index 00000000..aa2f0e2e --- /dev/null +++ b/mysql-test/suite/galera/include/galera_wsrep_recover.inc @@ -0,0 +1,30 @@ +--echo Performing --wsrep-recover ... +if ($wsrep_recover_additional) +{ +--exec $MYSQLD --defaults-group-suffix=.$galera_wsrep_recover_server_id --defaults-file=$MYSQLTEST_VARDIR/my.cnf --log-error=$MYSQL_TMP_DIR/galera_wsrep_recover.log --innodb --wsrep-recover $wsrep_recover_additional > $MYSQL_TMP_DIR/galera_wsrep_recover.log 2>&1 +} +if (!$wsrep_recover_additional) +{ +--exec $MYSQLD --defaults-group-suffix=.$galera_wsrep_recover_server_id --defaults-file=$MYSQLTEST_VARDIR/my.cnf --log-error=$MYSQL_TMP_DIR/galera_wsrep_recover.log --innodb --wsrep-recover > $MYSQL_TMP_DIR/galera_wsrep_recover.log 2>&1 +} + +--perl + use strict; + my $wsrep_start_position_str = "grep 'WSREP: Recovered position:' $ENV{MYSQL_TMP_DIR}/galera_wsrep_recover.log | sed 's/.*WSREP\:\ Recovered\ position://' | sed 's/^[ \t]*//'"; + my $wsrep_start_position = `grep 'WSREP: Recovered position:' $ENV{MYSQL_TMP_DIR}/galera_wsrep_recover.log | sed 's/.*WSREP\:\ Recovered\ position://' | sed 's/^[ \t]*//'`; + chomp($wsrep_start_position); + + die if $wsrep_start_position eq ''; + + open(FILE, ">", "$ENV{MYSQL_TMP_DIR}/galera_wsrep_start_position.inc") or die; + print FILE "--let \$galera_wsrep_start_position = $wsrep_start_position\n"; + close FILE; +EOF + +--source $MYSQL_TMP_DIR/galera_wsrep_start_position.inc + +if ($galera_wsrep_start_position == '') { + --die "Could not obtain wsrep_start_position." +} + +--remove_file $MYSQL_TMP_DIR/galera_wsrep_start_position.inc diff --git a/mysql-test/suite/galera/include/have_qpress.inc b/mysql-test/suite/galera/include/have_qpress.inc new file mode 100644 index 00000000..0dd693f2 --- /dev/null +++ b/mysql-test/suite/galera/include/have_qpress.inc @@ -0,0 +1,4 @@ +# +# suite.pm will make sure that all tests including this file +# will be skipped as needed +# diff --git a/mysql-test/suite/galera/include/have_stunnel.inc b/mysql-test/suite/galera/include/have_stunnel.inc new file mode 100644 index 00000000..0dd693f2 --- /dev/null +++ b/mysql-test/suite/galera/include/have_stunnel.inc @@ -0,0 +1,4 @@ +# +# suite.pm will make sure that all tests including this file +# will be skipped as needed +# diff --git a/mysql-test/suite/galera/include/kill_galera.inc b/mysql-test/suite/galera/include/kill_galera.inc new file mode 100644 index 00000000..28a1b0f3 --- /dev/null +++ b/mysql-test/suite/galera/include/kill_galera.inc @@ -0,0 +1,27 @@ +--echo Killing server ... + +if (!$kill_signal) +{ +--let $kill_signal = KILL +} + +# Write file to make mysql-test-run.pl expect the crash, but don't start it +--let $_expect_file_name= `select regexp_replace(@@tmpdir, '^.*/','')` +--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/$_expect_file_name.expect +--exec echo "wait" > $_expect_file_name + +# Kill the connected server +--disable_reconnect +--let KILL_SIGNAL_VALUE = $kill_signal +--let KILL_NODE_PIDFILE = `SELECT @@pid_file` + +--perl + my $kill_sig = $ENV{'KILL_SIGNAL_VALUE'}; + my $pid_filename = $ENV{'KILL_NODE_PIDFILE'}; + my $mysqld_pid = `cat $pid_filename`; + chomp($mysqld_pid); + system("kill -s $kill_sig $mysqld_pid"); + exit(0); +EOF + +--source include/wait_until_disconnected.inc diff --git a/mysql-test/suite/galera/include/print_gtid.inc b/mysql-test/suite/galera/include/print_gtid.inc new file mode 100644 index 00000000..e6bd627e --- /dev/null +++ b/mysql-test/suite/galera/include/print_gtid.inc @@ -0,0 +1,11 @@ +--echo list of GTID variables : +--disable_query_log +query_vertical +SELECT @@global.gtid_domain_id AS gtid_domain_id, + @@global.gtid_binlog_pos AS gtid_binlog_pos, + @@global.gtid_binlog_state AS gtid_binlog_state, + @@global.gtid_current_pos AS gtid_current_pos, + @@global.gtid_slave_pos AS gtid_slave_pos, + @@global.wsrep_gtid_domain_id AS wsrep_gtid_domain_id, + @@global.wsrep_gtid_mode AS wsrep_gtid_mode; +--enable_query_log diff --git a/mysql-test/suite/galera/include/reset_query_cache.inc b/mysql-test/suite/galera/include/reset_query_cache.inc new file mode 100644 index 00000000..6e33b886 --- /dev/null +++ b/mysql-test/suite/galera/include/reset_query_cache.inc @@ -0,0 +1,11 @@ +--disable_query_log +--disable_result_log +--connection node_1 +flush query cache; +reset query cache; + +--connection node_2 +flush query cache; +reset query cache; +--enable_result_log +--enable_query_log diff --git a/mysql-test/suite/galera/include/shutdown_mysqld.inc b/mysql-test/suite/galera/include/shutdown_mysqld.inc new file mode 100644 index 00000000..793be8d7 --- /dev/null +++ b/mysql-test/suite/galera/include/shutdown_mysqld.inc @@ -0,0 +1,18 @@ +# This is the first half of include/restart_mysqld.inc. +if ($rpl_inited) +{ + if (!$allow_rpl_inited) + { + --die ERROR IN TEST: When using the replication test framework (master-slave.inc, rpl_init.inc etc), use rpl_restart_server.inc instead of restart_mysqld.inc. If you know what you are doing and you really have to use restart_mysqld.inc, set allow_rpl_inited=1 before you source restart_mysqld.inc + } +} + +# Write file to make mysql-test-run.pl expect the "crash", but don't start it +--let $_expect_file_name= `select regexp_replace(@@tmpdir, '^.*/','')` +--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/$_expect_file_name.expect +--exec echo "wait" > $_expect_file_name + +# Send shutdown to the connected server +--shutdown_server +--source include/wait_until_disconnected.inc + diff --git a/mysql-test/suite/galera/include/start_mysqld.inc b/mysql-test/suite/galera/include/start_mysqld.inc new file mode 100644 index 00000000..57af9203 --- /dev/null +++ b/mysql-test/suite/galera/include/start_mysqld.inc @@ -0,0 +1,15 @@ +# Include this script only after using shutdown_mysqld.inc +# where $_expect_file_name was initialized. +# Write file to make mysql-test-run.pl start up the server again + +if ($galera_wsrep_start_position != '') { + --echo Using --wsrep-start-position when starting mysqld ... + --exec echo "restart:$start_mysqld_params --wsrep-start-position=$galera_wsrep_start_position" > $_expect_file_name + --let $galera_wsrep_start_position = 0 +} + +if ($galera_wsrep_start_position == '') { + --exec echo "restart:$start_mysqld_params" > $_expect_file_name +} + +--source include/galera_wait_ready.inc |