diff options
Diffstat (limited to 'mysql-test/suite/galera/t')
155 files changed, 5429 insertions, 27 deletions
diff --git a/mysql-test/suite/galera/t/galera_account_management.test b/mysql-test/suite/galera/t/galera_account_management.test new file mode 100644 index 00000000000..357319ad106 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_account_management.test @@ -0,0 +1,101 @@ +# +# Test the account management statements - GRANT, REVOKE, etc. +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +# +# CREATE USER +# +--connection node_1 +CREATE USER user1, user2 IDENTIFIED BY 'password'; + +--connection node_2 +SELECT COUNT(*) = 2 FROM mysql.user WHERE user IN ('user1', 'user2'); + +# +# ALTER USER +# + +# LP bug 1376269 +# +#--connection node_1 +#ALTER USER user1 PASSWORD EXPIRE; +#SELECT password_expired = 'Y' FROM mysql.user WHERE user = 'user1'; +# +#--connection node_2 +#SELECT password_expired = 'Y' FROM mysql.user WHERE user = 'user1'; + +# +# RENAME USER +# + +--connection node_1 +RENAME USER user2 TO user3; + +--connection node_2 +SELECT COUNT(*) = 0 FROM mysql.user WHERE user = 'user2'; +SELECT COUNT(*) = 1 FROM mysql.user WHERE user = 'user3'; + +# +# SET PASSWORD +# + +--connection node_1 +SET PASSWORD FOR user3 = PASSWORD('foo'); + +--connection node_1 +SELECT password != '' FROM mysql.user WHERE user = 'user3'; + +# +# DROP USER +# +--connection node_1 +DROP USER user1, user3; + +--connection node_2 +SELECT COUNT(*) = 0 FROM mysql.user WHERE user IN ('user1', 'user2'); + +# +# GRANT +# + +--connection node_1 +GRANT ALL ON *.* TO user4 IDENTIFIED BY 'password'; + +--connection node_2 +SELECT COUNT(*) = 1 FROM mysql.user WHERE user = 'user4'; +SELECT Select_priv = 'Y' FROM mysql.user WHERE user = 'user4'; + +# +# GRANT PROXY ON +# +--connection node_1 +CREATE USER user5; +GRANT PROXY ON user4 TO user5; + +--connection node_2 +SELECT COUNT(*) = 1 FROM mysql.proxies_priv WHERE user = 'user5'; + +# +# REVOKE +# + +--connection node_1 +REVOKE ALL PRIVILEGES ON *.* FROM user4; + +--connection node_2 +SELECT Select_priv = 'N' FROM mysql.user WHERE user = 'user4'; + +# +# REVOKE PROXY +# + +--connection node_1 +REVOKE PROXY ON user4 FROM user5; + +--connection node_2 +SELECT COUNT(*) = 0 FROM mysql.proxies_priv WHERE user = 'user5'; + +DROP USER user4, user5; diff --git a/mysql-test/suite/galera/t/galera_alter_engine_innodb.test b/mysql-test/suite/galera/t/galera_alter_engine_innodb.test new file mode 100644 index 00000000000..bc914a38776 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_alter_engine_innodb.test @@ -0,0 +1,17 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc + +# +# Test ALTER ENGINE from InnoDB to InnoDB +# + +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); + +ALTER TABLE t1 ENGINE=InnoDB; + +--connection node_2 +SELECT ENGINE = 'InnoDB' FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; +SELECT COUNT(*) = 1 FROM t1; + +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_alter_engine_myisam.test b/mysql-test/suite/galera/t/galera_alter_engine_myisam.test new file mode 100644 index 00000000000..6d41d276a17 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_alter_engine_myisam.test @@ -0,0 +1,25 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc + +# +# Test ALTER ENGINE from MyISAM to InnoDB under wsrep_replicate_myisam +# + +--let $wsrep_replicate_myisam_orig = `SELECT @@wsrep_replicate_myisam` +SET GLOBAL wsrep_replicate_myisam = TRUE; + +CREATE TABLE t1 (f1 INTEGER) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1); + +ALTER TABLE t1 ENGINE=InnoDB; + +--connection node_2 +SELECT ENGINE = 'InnoDB' FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; +SELECT COUNT(*) = 1 FROM t1; + +--connection node_1 +--disable_query_log +--eval SET GLOBAL wsrep_replicate_myisam = $wsrep_replicate_myisam_orig +--enable_query_log + +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_alter_table_force.test b/mysql-test/suite/galera/t/galera_alter_table_force.test new file mode 100644 index 00000000000..1fcc9d4bda5 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_alter_table_force.test @@ -0,0 +1,17 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc + +# +# Test ALTER TABLE FORCE, a 5.6.3 feature that simply rebuilds the table +# + +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); + +ALTER TABLE t1 FORCE; + +--connection node_2 +SELECT ENGINE = 'InnoDB' FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; +SELECT COUNT(*) = 1 FROM t1; + +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_as_master.cnf b/mysql-test/suite/galera/t/galera_as_master.cnf new file mode 100644 index 00000000000..52fd3093931 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_as_master.cnf @@ -0,0 +1 @@ +!include ../galera_2nodes_as_master.cnf diff --git a/mysql-test/suite/galera/t/galera_as_master.test b/mysql-test/suite/galera/t/galera_as_master.test new file mode 100644 index 00000000000..c42dbbf9683 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_as_master.test @@ -0,0 +1,38 @@ +# +# Test Galera as a master to a MySQL slave +# +# The galera/galera_2node_master.cnf describes the setup of the nodes +# + +--source include/have_innodb.inc +--source include/galera_cluster.inc + +--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3 +--disable_query_log +--eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_USER='root', MASTER_PORT=$NODE_MYPORT_1; +--enable_query_log +START SLAVE; + +--connection node_1 +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES(1); + +--connection node_2 +INSERT INTO t1 VALUES(2); + +--connection node_3 +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; +--source include/wait_condition.inc + +--let $wait_condition = SELECT COUNT(*) = 2 FROM t1; +--source include/wait_condition.inc + +--connection node_1 +DROP TABLE t1; + +--connection node_3 +--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; +--source include/wait_condition.inc + +STOP SLAVE; +RESET SLAVE ALL; diff --git a/mysql-test/suite/galera/t/galera_as_master_gtid.cnf b/mysql-test/suite/galera/t/galera_as_master_gtid.cnf new file mode 100644 index 00000000000..19517556331 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_as_master_gtid.cnf @@ -0,0 +1,8 @@ +!include ../galera_2nodes_as_master.cnf + +[mysqld] +gtid-mode=ON +log-bin=mysqld-bin +log-slave-updates +enforce-gtid-consistency +binlog-format=ROW diff --git a/mysql-test/suite/galera/t/galera_as_master_gtid.test b/mysql-test/suite/galera/t/galera_as_master_gtid.test new file mode 100644 index 00000000000..9db104b7cab --- /dev/null +++ b/mysql-test/suite/galera/t/galera_as_master_gtid.test @@ -0,0 +1,70 @@ +# +# Test Galera as a master to a MySQL slave with GTID +# +# The galera/galera_2node_master.cnf describes the setup of the nodes +# +# We check that all transactions originating from within Galera use a UUID that is +# different from the server_uuid of either node +# +# + +--source include/have_innodb.inc +--source include/have_log_bin.inc +--source include/galera_cluster.inc + +--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3 +--disable_query_log +--eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$NODE_MYPORT_1; +--enable_query_log +START SLAVE USER='root'; + +--connection node_1 +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES(1); + +--let $effective_uuid = `SELECT LEFT(@@global.gtid_executed, 36)` +--disable_query_log +--eval SELECT '$effective_uuid' != @@global.server_uuid AS uuids_do_not_match; +--enable_query_log + +--replace_result $effective_uuid <effective_uuid> +--replace_regex /table_id: [0-9]+/table_id: #/ /xid=[0-9]+/xid=#/ +SHOW BINLOG EVENTS IN 'mysqld-bin.000002' FROM 120; + +--connection node_2 +INSERT INTO t1 VALUES(2); + +--disable_query_log +--eval SELECT '$effective_uuid' != @@global.server_uuid AS uuids_do_not_match; +--eval SELECT '$effective_uuid' = LEFT(@@global.gtid_executed, 36) AS uuids_match; +--enable_query_log + +--replace_result $effective_uuid <effective_uuid> +--replace_regex /table_id: [0-9]+/table_id: #/ /xid=[0-9]+/xid=#/ +SHOW BINLOG EVENTS IN 'mysqld-bin.000003' FROM 120; + +--connection node_3 +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; +--source include/wait_condition.inc + +--let $wait_condition = SELECT COUNT(*) = 2 FROM t1; +--source include/wait_condition.inc + +--disable_query_log +--eval SELECT '$effective_uuid' != @@global.server_uuid AS uuids_do_not_match; +--eval SELECT '$effective_uuid' = LEFT(@@global.gtid_executed, 36) AS uuids_match; +--enable_query_log + +--replace_result $effective_uuid <effective_uuid> +--replace_regex /table_id: [0-9]+/table_id: #/ /xid=[0-9]+/xid=#/ +SHOW BINLOG EVENTS IN 'mysqld-bin.000001' FROM 120; + +--connection node_1 +DROP TABLE t1; + +--connection node_3 +--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; +--source include/wait_condition.inc + +STOP SLAVE; +RESET SLAVE ALL; diff --git a/mysql-test/suite/galera/t/galera_as_master_gtid_change_master.cnf b/mysql-test/suite/galera/t/galera_as_master_gtid_change_master.cnf new file mode 100644 index 00000000000..19517556331 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_as_master_gtid_change_master.cnf @@ -0,0 +1,8 @@ +!include ../galera_2nodes_as_master.cnf + +[mysqld] +gtid-mode=ON +log-bin=mysqld-bin +log-slave-updates +enforce-gtid-consistency +binlog-format=ROW diff --git a/mysql-test/suite/galera/t/galera_as_master_gtid_change_master.test b/mysql-test/suite/galera/t/galera_as_master_gtid_change_master.test new file mode 100644 index 00000000000..23606d7ac4c --- /dev/null +++ b/mysql-test/suite/galera/t/galera_as_master_gtid_change_master.test @@ -0,0 +1,54 @@ +# +# Test that a MySQL slave can use CHANGE MASTER MASTER_AUTO_POSITION to begin replicating +# from another Galera node +# +# The galera/galera_2node_master.cnf describes the setup of the nodes +# +# + +--source include/have_innodb.inc +--source include/have_log_bin.inc +--source include/galera_cluster.inc + +--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3 +--disable_query_log +--eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$NODE_MYPORT_1; +--enable_query_log +START SLAVE USER='root'; + +--connection node_1 +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES(1); + +--connection node_2 +INSERT INTO t1 VALUES(2); + +--connection node_3 +STOP SLAVE; +--disable_query_log +--eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$NODE_MYPORT_2, MASTER_AUTO_POSITION=1; +--enable_query_log +START SLAVE USER='root'; + +--connection node_1 +INSERT INTO t1 VALUES(3); + +--connection node_2 +INSERT INTO t1 VALUES(4); + +--connection node_3 +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; +--source include/wait_condition.inc + +--let $wait_condition = SELECT COUNT(*) = 4 FROM t1; +--source include/wait_condition.inc + +--connection node_1 +DROP TABLE t1; + +--connection node_3 +--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; +--source include/wait_condition.inc + +STOP SLAVE; +RESET SLAVE ALL; diff --git a/mysql-test/suite/galera/t/galera_as_slave.cnf b/mysql-test/suite/galera/t/galera_as_slave.cnf new file mode 100644 index 00000000000..9449ec9cf40 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_as_slave.cnf @@ -0,0 +1 @@ +!include ../galera_2nodes_as_slave.cnf diff --git a/mysql-test/suite/galera/t/galera_as_slave.test b/mysql-test/suite/galera/t/galera_as_slave.test new file mode 100644 index 00000000000..79b9e5071a3 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_as_slave.test @@ -0,0 +1,47 @@ +# +# Test Galera as a slave to a MySQL master +# +# The galera/galera_2node_slave.cnf describes the setup of the nodes +# + +--source include/have_innodb.inc + +# As node #1 is not a Galera node, we connect to node #2 in order to run include/galera_cluster.inc +--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2 +--source include/galera_cluster.inc + +--connection node_2 +--disable_query_log +--eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_USER='root', MASTER_PORT=$NODE_MYPORT_1; +--enable_query_log +START SLAVE; + +--connection node_1 +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES(1); + +--connection 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 t1; +--source include/wait_condition.inc + +INSERT INTO t1 VALUES (2); + +--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3 +SELECT COUNT(*) = 2 FROM t1; +INSERT INTO t1 VALUES (3); + +--connection node_2 +SELECT COUNT(*) = 3 FROM t1; + +--connection node_1 +DROP TABLE t1; + +--connection node_2 +--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; +--source include/wait_condition.inc + +STOP SLAVE; +RESET SLAVE ALL; diff --git a/mysql-test/suite/galera/t/galera_as_slave_gtid.cnf b/mysql-test/suite/galera/t/galera_as_slave_gtid.cnf new file mode 100644 index 00000000000..01d2eb12630 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_as_slave_gtid.cnf @@ -0,0 +1,6 @@ +!include ../galera_2nodes_as_slave.cnf + +[mysqld] +log-bin=mysqld-bin +log-slave-updates +binlog-format=ROW diff --git a/mysql-test/suite/galera/t/galera_as_slave_gtid.test b/mysql-test/suite/galera/t/galera_as_slave_gtid.test new file mode 100644 index 00000000000..c2331a2ae05 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_as_slave_gtid.test @@ -0,0 +1,67 @@ +# +# Test Galera as a slave to a MariaDB master using GTIDs +# +# suite/galera/galera_2nodes_as_slave.cnf describes the setup of the nodes +# suite/galera/t/galera_as_slave_gtid.cnf has the GTID options +# +# In addition to performing DDL and DML, we check that the gtid of the master is preserved inside the cluster +# + +--source include/have_innodb.inc + +# As node #1 is not a Galera node, we connect to node #2 in order to run include/galera_cluster.inc +--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2 +--source include/galera_cluster.inc + +--connection node_2 +--disable_query_log +--eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_USER='root', MASTER_PORT=$NODE_MYPORT_1; +--enable_query_log +START SLAVE; + +--connection node_1 +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES(1); + +SELECT LENGTH(@@global.gtid_binlog_state) > 1; +--let $gtid_binlog_state_node1 = `SELECT @@global.gtid_binlog_state;` + +--connection 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 t1; +--source include/wait_condition.inc + +--disable_query_log +--eval SELECT '$gtid_binlog_state_node1' = @@global.gtid_binlog_state AS gtid_binlog_state_equal; +--enable_query_log + +--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3 +SELECT COUNT(*) = 1 FROM t1; + +--disable_query_log +--eval SELECT '$gtid_binlog_state_node1' = @@global.gtid_binlog_state AS gtid_binlog_state_equal; +--enable_query_log + +--connection node_1 +DROP TABLE t1; + +# +# Unfortunately without the sleep below the following statement fails with "query returned no rows", which +# is difficult to understand given that it is an aggregate query. A "query execution was interrupted" +# warning is also reported by MTR, which is also weird. +# + +--sleep 1 + +--connection node_3 +--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; +--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 + +STOP SLAVE; +RESET SLAVE ALL; diff --git a/mysql-test/suite/galera/t/galera_bf_abort.test b/mysql-test/suite/galera/t/galera_bf_abort.test new file mode 100644 index 00000000000..69825ea4919 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_bf_abort.test @@ -0,0 +1,29 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc + +# +# Test a local transaction being aborted by a slave one +# + +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; + +--connection node_2 +--let $wsrep_local_bf_aborts_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_bf_aborts'` +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (1); + +--connection node_1 +INSERT INTO t1 VALUES (1); + +--connection node_2 +--error ER_LOCK_DEADLOCK +INSERT INTO t1 VALUES (2); + +--let $wsrep_local_bf_aborts_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_bf_aborts'` + +--disable_query_log +--eval SELECT $wsrep_local_bf_aborts_after - $wsrep_local_bf_aborts_before = 1 AS wsrep_local_aborts_increment; +--enable_query_log + +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_bf_abort_for_update.test b/mysql-test/suite/galera/t/galera_bf_abort_for_update.test new file mode 100644 index 00000000000..24c29778e5d --- /dev/null +++ b/mysql-test/suite/galera/t/galera_bf_abort_for_update.test @@ -0,0 +1,29 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc + +# +# Test a local transaction being aborted by a slave one while it is running a SELECT FOR UPDATE +# + +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; + +--connection node_2 +--let $wsrep_local_bf_aborts_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_bf_aborts'` +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (1); + +--connection node_1 +INSERT INTO t1 VALUES (1); + +--connection node_2 +--error ER_LOCK_DEADLOCK +SELECT * FROM t1 FOR UPDATE; + +--let $wsrep_local_bf_aborts_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_bf_aborts'` + +--disable_query_log +--eval SELECT $wsrep_local_bf_aborts_after - $wsrep_local_bf_aborts_before = 1 AS wsrep_local_aborts_increment; +--enable_query_log + +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_bf_abort_ftwrl.test b/mysql-test/suite/galera/t/galera_bf_abort_ftwrl.test new file mode 100644 index 00000000000..44398e717d1 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_bf_abort_ftwrl.test @@ -0,0 +1,30 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc + +# +# A local transaction running FLUSH TABLES WITH READ LOCK will not be aborted by a slave transaction +# + +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; + +--connection node_2 +SET AUTOCOMMIT=OFF; +--let $wsrep_local_bf_aborts_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_bf_aborts'` +--send FLUSH TABLES WITH READ LOCK; + +--connection node_1 +INSERT INTO t1 VALUES (1); + +--connection node_2 +--reap + +UNLOCK TABLES; + +--let $wsrep_local_bf_aborts_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_bf_aborts'` + +# No aborts should be registered on the counter +--disable_query_log +--eval SELECT $wsrep_local_bf_aborts_after - $wsrep_local_bf_aborts_before = 0 AS wsrep_local_aborts_increment; +--enable_query_log + +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_bf_abort_get_lock.test b/mysql-test/suite/galera/t/galera_bf_abort_get_lock.test new file mode 100644 index 00000000000..72fc1c5b583 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_bf_abort_get_lock.test @@ -0,0 +1,36 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc + +# +# Test a local transaction being aborted by a slave one while it is running a GET_LOCK() +# + +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; + +--let $galera_connection_name = node_2a +--let $galera_server_number = 2 +--source include/galera_connect.inc +--connection node_2a +SELECT GET_LOCK("foo", 1000); + +--connection node_2 +SET AUTOCOMMIT=OFF; +--let $wsrep_local_bf_aborts_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_bf_aborts'` +INSERT INTO t1 VALUES (1); +--send SELECT GET_LOCK("foo", 1000); + +--connection node_1 +INSERT INTO t1 VALUES (1); + +--connection node_2 +--error ER_LOCK_DEADLOCK +--reap + +--let $wsrep_local_bf_aborts_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_bf_aborts'` + +# Check that wsrep_local_bf_aborts has been incremented by exactly 1 +--disable_query_log +--eval SELECT $wsrep_local_bf_aborts_after - $wsrep_local_bf_aborts_before = 1 AS wsrep_local_aborts_increment; +--enable_query_log + +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_bf_abort_lock_table.test b/mysql-test/suite/galera/t/galera_bf_abort_lock_table.test new file mode 100644 index 00000000000..788427103a5 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_bf_abort_lock_table.test @@ -0,0 +1,33 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc + +# +# Test that a local LOCK TABLE will be broken by an incoming remote transaction against that table +# + +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; + +--connection node_2 +SET AUTOCOMMIT=OFF; +--let $wsrep_local_bf_aborts_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_bf_aborts'` +LOCK TABLE t1 WRITE; + +# Issue a concurrent INSERT against the lock table that will block +--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2 +--send INSERT INTO t1 VALUES (1); + +--connection node_1 +INSERT INTO t1 VALUES (2); + +# The concurent insert is allowed to complete because the LOCK TABLE is now broken +--connection node_2a +--error 0 +--reap + +--let $wsrep_local_bf_aborts_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_bf_aborts'` + +--disable_query_log +--eval SELECT $wsrep_local_bf_aborts_after - $wsrep_local_bf_aborts_before = 1 AS wsrep_local_aborts_increment; +--enable_query_log + +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_bf_abort_sleep.test b/mysql-test/suite/galera/t/galera_bf_abort_sleep.test new file mode 100644 index 00000000000..8d135dc7d42 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_bf_abort_sleep.test @@ -0,0 +1,30 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc + +# +# Test a local transaction being aborted by a slave one while it is running a SLEEP() +# + +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; + +--connection node_2 +SET AUTOCOMMIT=OFF; +--let $wsrep_local_bf_aborts_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_bf_aborts'` +INSERT INTO t1 VALUES (1); +--send SELECT SLEEP(1000); + +--connection node_1 +INSERT INTO t1 VALUES (1); + +--connection node_2 +--error ER_LOCK_DEADLOCK +--reap + +--let $wsrep_local_bf_aborts_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_bf_aborts'` + +# Check that wsrep_local_bf_aborts has been incremented by exactly 1 +--disable_query_log +--eval SELECT $wsrep_local_bf_aborts_after - $wsrep_local_bf_aborts_before = 1 AS wsrep_local_aborts_increment; +--enable_query_log + +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_binlog_cache_size.test b/mysql-test/suite/galera/t/galera_binlog_cache_size.test new file mode 100644 index 00000000000..6ce9072d412 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_binlog_cache_size.test @@ -0,0 +1,35 @@ +# +# Test that Galera, like the stock MySQL, returns an error on transactions +# larger than max_binlog_cache_size +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +CREATE TABLE t1 (f1 VARCHAR(767)) ENGINE=InnoDB; +CREATE TABLE ten (f1 INTEGER); +INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); + +--let $max_binlog_cache_size_orig = `SELECT @@max_binlog_cache_size` +--let $binlog_cache_size_orig = `SELECT @@binlog_cache_size` + +SET GLOBAL binlog_cache_size=4096; +SET GLOBAL max_binlog_cache_size=4096; + +--let $galera_connection_name = node_1a +--let $galera_server_number = 1 +--source include/galera_connect.inc +--connection node_1a +SET AUTOCOMMIT=ON; +START TRANSACTION; +INSERT INTO t1 SELECT REPEAT('a', 767) FROM ten; +--error ER_TRANS_CACHE_FULL +INSERT INTO t1 SELECT REPEAT('a', 767) FROM ten; + +--disable_query_log +--eval SET GLOBAL max_binlog_cache_size = $max_binlog_cache_size_orig +--eval SET GLOBAL binlog_cache_size = $binlog_cache_size_orig +--enable_query_log + +DROP TABLE t1; +DROP TABLE ten; diff --git a/mysql-test/suite/galera/t/galera_binlog_checksum-master.opt b/mysql-test/suite/galera/t/galera_binlog_checksum-master.opt new file mode 100644 index 00000000000..c8e53f07fc2 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_binlog_checksum-master.opt @@ -0,0 +1 @@ +--binlog-checksum=CRC32 --master-verify-checksum=1 --slave-sql-verify-checksum=1 diff --git a/mysql-test/suite/galera/t/galera_binlog_checksum.test b/mysql-test/suite/galera/t/galera_binlog_checksum.test new file mode 100644 index 00000000000..48669305242 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_binlog_checksum.test @@ -0,0 +1,22 @@ +# +# Test that Galera works with binary log checksums. +# The galera_binlog_checksum-master.opt file is used to enable checksums. +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +CREATE TABLE t1 (f1 INT PRIMARY KEY) ENGINE=InnoDB; + +INSERT INTO t1 VALUES (1); + +--connection node_2 +SELECT COUNT(*) = 1 FROM t1; + +--connection node_1 +UPDATE t1 SET f1 = 2 WHERE f1 = 1; + +--connection node_2 +SELECT COUNT(*) = 1 FROM t1 WHERE f1 = 2; + +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_binlog_event_max_size_max-master.opt b/mysql-test/suite/galera/t/galera_binlog_event_max_size_max-master.opt new file mode 100644 index 00000000000..a36d21315a6 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_binlog_event_max_size_max-master.opt @@ -0,0 +1 @@ +--binlog-row-event-max-size=4294967295 diff --git a/mysql-test/suite/galera/t/galera_binlog_event_max_size_max.test b/mysql-test/suite/galera/t/galera_binlog_event_max_size_max.test new file mode 100644 index 00000000000..600432ce0ca --- /dev/null +++ b/mysql-test/suite/galera/t/galera_binlog_event_max_size_max.test @@ -0,0 +1,20 @@ +# +# Test that replication works event with the maximum value of binlog-row-event-max-size - 4294967295 (on 32-bit platforms) +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +CREATE TABLE ten (f1 INTEGER); +INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); + +CREATE TABLE t1 (f1 VARCHAR(1000)); + +# Insert 10K records, 1K bytes each +INSERT INTO t1 SELECT REPEAT('x', 1000) FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4; + +--connection node_2 +SELECT COUNT(*) = 10000 FROM t1; + +DROP TABLE t1; +DROP TABLE ten; diff --git a/mysql-test/suite/galera/t/galera_binlog_event_max_size_min-master.opt b/mysql-test/suite/galera/t/galera_binlog_event_max_size_min-master.opt new file mode 100644 index 00000000000..22174756652 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_binlog_event_max_size_min-master.opt @@ -0,0 +1 @@ +--binlog-row-event-max-size=256 diff --git a/mysql-test/suite/galera/t/galera_binlog_event_max_size_min.test b/mysql-test/suite/galera/t/galera_binlog_event_max_size_min.test new file mode 100644 index 00000000000..00b55339770 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_binlog_event_max_size_min.test @@ -0,0 +1,15 @@ +# +# Test that replication works event with the minimum value of binlog-row-event-max-size - 256 +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +CREATE TABLE t1 (f1 VARCHAR(1000)); +INSERT INTO t1 VALUES (REPEAT('x', 1000)); + +--connection node_2 +SELECT COUNT(*) = 1 FROM t1 WHERE f1 = REPEAT('x', 1000); + +DROP TABLE t1; + diff --git a/mysql-test/suite/galera/t/galera_binlog_row_image.test b/mysql-test/suite/galera/t/galera_binlog_row_image.test new file mode 100644 index 00000000000..70262ec44ca --- /dev/null +++ b/mysql-test/suite/galera/t/galera_binlog_row_image.test @@ -0,0 +1,100 @@ +# +# Test the operation on the different values of the binlog_row_image option +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +# +# binlog_row_image = minimal +# + +--connection node_1 +SET SESSION binlog_row_image=minimal; + +# Create a table with a PK, with a unique key and with no key +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; +CREATE TABLE t2 (f1 INTEGER NOT NULL UNIQUE) ENGINE=InnoDB; +CREATE TABLE t3 (f1 VARCHAR(1)) ENGINE=InnoDB; + +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1); +INSERT INTO t3 VALUES (1); + +--connection node_2 +SELECT COUNT(*) = 1 FROM t1 WHERE f1 = 1; +SELECT COUNT(*) = 1 FROM t2 WHERE f1 = 1; +SELECT COUNT(*) = 1 FROM t3 WHERE f1 = 1; + +--connection node_1 +UPDATE t1 SET f1 = 2 WHERE f1 = 1; +UPDATE t2 SET f1 = 2 WHERE f1 = 1; +UPDATE t3 SET f1 = 2 WHERE f1 = 1; + +--connection node_2 +SELECT COUNT(*) = 1 FROM t1 WHERE f1 = 2; +SELECT COUNT(*) = 1 FROM t2 WHERE f1 = 2; +SELECT COUNT(*) = 1 FROM t3 WHERE f1 = 2; + +--connection node_1 +DELETE FROM t1; +DELETE FROM t2; +DELETE FROM t3; + +--connection node_2 +SELECT COUNT(*) = 0 FROM t1; +SELECT COUNT(*) = 0 FROM t2; +SELECT COUNT(*) = 0 FROM t3; + +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE t3; + +# +# binlog_row_image = noblob +# + +# A table with only a blob, and a table with a PK and a blob + +--connection node_1 +SET SESSION binlog_row_image=noblob; + +CREATE TABLE t1 (f1 BLOB, f2 INTEGER PRIMARY KEY) ENGINE=InnoDB; +CREATE TABLE t2 (f1 BLOB) ENGINE=InnoDB; + +INSERT INTO t1 VALUES ('abc', 1); +INSERT INTO t2 VALUES ('abc'); + +--connection node_2 +SELECT COUNT(*) = 1 FROM t1 WHERE f1 = 'abc'; +SELECT COUNT(*) = 1 FROM t2 WHERE f1 = 'abc'; + +--connection node_1 +UPDATE t1 SET f1 = 'xyz'; +UPDATE t2 SET f1 = 'xyz'; + +--connection node_2 +SELECT COUNT(*) = 1 FROM t1 WHERE f1 = 'xyz'; +SELECT COUNT(*) = 1 FROM t2 WHERE f1 = 'xyz'; + +--connection node_1 +UPDATE t1 SET f2 = 2 WHERE f2 = 1; + +--connection node_2 +SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 2; +SELECT COUNT(*) = 1 FROM t1 WHERE f1 = 'xyz'; + +--connection node_1 +DELETE FROM t1; +DELETE FROM t2; + +--connection node_2 +SELECT COUNT(*) = 0 FROM t1; +SELECT COUNT(*) = 0 FROM t2; + +DROP TABLE t1; +DROP TABLE t2; + + + + diff --git a/mysql-test/suite/galera/t/galera_binlog_rows_query_log_events.test b/mysql-test/suite/galera/t/galera_binlog_rows_query_log_events.test new file mode 100644 index 00000000000..95bc85c4cab --- /dev/null +++ b/mysql-test/suite/galera/t/galera_binlog_rows_query_log_events.test @@ -0,0 +1,28 @@ +# +# Test that Galera continues to run even with binlog-rows-query-log-events=TRUE +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +--let $binlog_rows_query_log_events_orig = `SELECT @@binlog_rows_query_log_events` + +SET GLOBAL binlog_rows_query_log_events=TRUE; + +CREATE TABLE t1 (f1 INT PRIMARY KEY) ENGINE=InnoDB; + +INSERT INTO t1 VALUES (1); + +--connection node_2 +SELECT COUNT(*) = 1 FROM t1; + +--connection node_1 +UPDATE t1 SET f1 = 2 WHERE f1 = 1; + +--connection node_2 +SELECT COUNT(*) = 1 FROM t1 WHERE f1 = 2; + +--connection node_1 +--eval SET GLOBAL binlog_rows_query_log_events = $binlog_rows_query_log_events_orig + +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_create_function.test b/mysql-test/suite/galera/t/galera_create_function.test new file mode 100644 index 00000000000..fd4903a7b83 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_create_function.test @@ -0,0 +1,57 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc + +# +# Test CREATE FUNCTION +# + +--connection node_1 +CREATE USER 'user1'; + +CREATE +DEFINER = 'user1' +FUNCTION f1 (param INTEGER) +RETURNS VARCHAR(200) +COMMENT 'f1_comment' +LANGUAGE SQL +NOT DETERMINISTIC +MODIFIES SQL DATA +SQL SECURITY DEFINER +RETURN 'abc'; +GRANT EXECUTE ON FUNCTION f1 TO user1; + +CREATE +DEFINER = CURRENT_USER +FUNCTION f2 (param VARCHAR(100)) +RETURNS INTEGER +DETERMINISTIC +NO SQL +SQL SECURITY INVOKER +RETURN 123; + +--connection node_1 +SHOW CREATE FUNCTION f1; + +--connection node_2 +SHOW CREATE FUNCTION f1; + +--connection node_1 +SHOW CREATE FUNCTION f2; + +--connection node_2 +SHOW CREATE FUNCTION f2; + +SELECT f1(1) = 'abc'; +SELECT f2('abc') = 123; + +--connection node_1 +DROP FUNCTION f1; +DROP FUNCTION f2; + +DROP USER 'user1'; + + + + + + diff --git a/mysql-test/suite/galera/t/galera_create_procedure.test b/mysql-test/suite/galera/t/galera_create_procedure.test new file mode 100644 index 00000000000..30bc85fcea0 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_create_procedure.test @@ -0,0 +1,52 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc + +# +# Test CREATE PROCEDURE +# + +--connection node_1 +CREATE USER 'user1'; +CREATE TABLE t1 (f1 INTEGER); + +CREATE +DEFINER = 'user1' +PROCEDURE p1 (IN param1 INTEGER, OUT param2 INTEGER, INOUT param3 INTEGER) +COMMENT 'p1_comment' +LANGUAGE SQL +NOT DETERMINISTIC +MODIFIES SQL DATA +SQL SECURITY DEFINER +INSERT INTO t1 VALUES (1); +GRANT EXECUTE ON PROCEDURE p1 TO user1; + +CREATE +DEFINER = CURRENT_USER +PROCEDURE p2 (param VARCHAR(100)) +DETERMINISTIC +NO SQL +SQL SECURITY INVOKER BEGIN END ; + +--connection node_1 +SHOW CREATE PROCEDURE p1; + +--connection node_2 +# Perform causal wait +SELECT 1 FROM DUAL; +SHOW CREATE PROCEDURE p1; + +--connection node_1 +SHOW CREATE PROCEDURE p2; + +--connection node_2 +SHOW CREATE PROCEDURE p2; + +CALL p1(@a, @b, @c); +CALL p2('abc'); + +--connection node_1 +DROP PROCEDURE p1; +DROP PROCEDURE p2; + +DROP USER 'user1'; +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_create_table_like.test b/mysql-test/suite/galera/t/galera_create_table_like.test new file mode 100644 index 00000000000..0e0e8b0ffcf --- /dev/null +++ b/mysql-test/suite/galera/t/galera_create_table_like.test @@ -0,0 +1,50 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc + +# +# Test the various forms of CREATE TABLE LIKE ... , since Galera has special handling +# for them, especially when one of the tables is a temporary one. +# + +CREATE SCHEMA schema1; +CREATE SCHEMA schema2; + +USE schema1; +CREATE TABLE real_table (f1 INTEGER) ENGINE=InnoDB; +CREATE TEMPORARY TABLE temp_table (f1 INTEGER) ENGINE=InnoDB; +CREATE TABLE myisam_table (f1 INTEGER) ENGINE=MyISAM; + +USE schema2; +CREATE TABLE real_table1 LIKE schema1.real_table; +CREATE TABLE real_table2 LIKE schema1.temp_table; +CREATE TABLE real_table3 LIKE schema1.myisam_table; + +CREATE TEMPORARY TABLE temp_table1 LIKE schema1.real_table; +CREATE TEMPORARY TABLE temp_table2 LIKE schema1.temp_table; +CREATE TEMPORARY TABLE temp_table3 LIKE schema1.myisam_table; + +--connection node_2 +# Only the non-temporary tables are replicated, regardless of the type of table they are based on + +SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'real_table' AND TABLE_SCHEMA = 'schema1'; +SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'myisam_table' AND TABLE_SCHEMA = 'schema1'; +SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'temp_table' AND TABLE_SCHEMA = 'schema1'; + +SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'real_table1' AND TABLE_SCHEMA = 'schema2'; +SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'real_table2' AND TABLE_SCHEMA = 'schema2'; +SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'real_table3' AND TABLE_SCHEMA = 'schema2'; + +SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'temp_table1' AND TABLE_SCHEMA = 'schema2'; +SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'temp_table2' AND TABLE_SCHEMA = 'schema2'; +SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'temp_table3' AND TABLE_SCHEMA = 'schema2'; + +--connection node_1 +DROP TABLE schema1.real_table; +DROP TABLE schema1.myisam_table; + +DROP TABLE schema2.real_table1; +DROP TABLE schema2.real_table2; +DROP TABLE schema2.real_table3; + +DROP SCHEMA schema1; +DROP SCHEMA schema2; diff --git a/mysql-test/suite/galera/t/galera_defaults.test b/mysql-test/suite/galera/t/galera_defaults.test new file mode 100644 index 00000000000..995e0b4c451 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_defaults.test @@ -0,0 +1,69 @@ +# +# The purpose of this test is to preserve the current state of the following: +# * SHOW VARIABLES LIKE 'wsrep%' +# * wsrep_provider_options +# * The names of the Galera status variables +# +# This way, if there is any change, inadvertent or not, the test will fail and the +# developer and QA will be alerted. +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +# Make sure that the test is operating on the right version of galera library. +--disable_query_log +--let $galera_version=3.9 +source ../wsrep/include/check_galera_version.inc; +--enable_query_log + +# Global Variables + +SELECT COUNT(*) = 39 FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME LIKE 'wsrep_%'; + +SELECT VARIABLE_NAME, VARIABLE_VALUE +FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES +WHERE VARIABLE_NAME LIKE 'wsrep_%' +AND VARIABLE_NAME NOT IN ( + 'WSREP_PROVIDER_OPTIONS', + 'WSREP_SST_RECEIVE_ADDRESS', + 'WSREP_NODE_ADDRESS', + 'WSREP_NODE_NAME', + 'WSREP_PROVIDER', + 'WSREP_DATA_HOME_DIR', + 'WSREP_NODE_INCOMING_ADDRESS', + 'WSREP_START_POSITION' +) +ORDER BY VARIABLE_NAME; + +# wsrep_provider_options +# +# We replace the ones that vary from run to run with placeholders + +--let _WSREP_PROVIDER_OPTIONS = `SELECT @@wsrep_provider_options` +--perl + use strict; + my $wsrep_provider_options = $ENV{'_WSREP_PROVIDER_OPTIONS'}; + $wsrep_provider_options =~ s/base_dir = .*?;/<BASE_DIR>;/sgio; + $wsrep_provider_options =~ s/base_host = .*?;/<BASE_HOST>;/sgio; + $wsrep_provider_options =~ s/base_port = .*?;/<BASE_PORT>;/sgio; + $wsrep_provider_options =~ s/gcache\.dir = .*?;/<GCACHE_DIR>;/sgio; + $wsrep_provider_options =~ s/gcache\.name = .*?;/<GCACHE_NAME>;/sgio; + $wsrep_provider_options =~ s/gmcast\.listen_addr = .*?;/<GMCAST_LISTEN_ADDR>;/sgio; + $wsrep_provider_options =~ s/ist\.recv_addr = .*?;/<IST_RECV_ADDR>;/sgio; + $wsrep_provider_options =~ s/evs\.evict = .*?;/<EVS_EVICT>;/sgio; + $wsrep_provider_options =~ s/signal = .*?;\s*//sgio; + $wsrep_provider_options =~ s/dbug = .*?;\s*//sgio; + print $wsrep_provider_options."\n"; +EOF + +# Global Status + +SELECT COUNT(*) FROM INFORMATION_SCHEMA.GLOBAL_STATUS +WHERE VARIABLE_NAME LIKE 'wsrep_%' +AND VARIABLE_NAME != 'wsrep_debug_sync_waiters'; + +SELECT VARIABLE_NAME FROM INFORMATION_SCHEMA.GLOBAL_STATUS +WHERE VARIABLE_NAME LIKE 'wsrep_%' +AND VARIABLE_NAME != 'wsrep_debug_sync_waiters' +ORDER BY VARIABLE_NAME; diff --git a/mysql-test/suite/galera/t/galera_delete_limit.test b/mysql-test/suite/galera/t/galera_delete_limit.test new file mode 100644 index 00000000000..4cbadbd3ba0 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_delete_limit.test @@ -0,0 +1,52 @@ +# +# DELETE LIMIT should not cause any issues with row-based Galera replication +# regardless of the order in which the rows were deleted +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +# +# With a PK +# + +--connection node_1 +CREATE TABLE ten (f1 INTEGER) Engine=InnoDB; +INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); + +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) Engine=InnoDB; +INSERT INTO t1 SELECT f1 FROM ten ORDER BY RAND(); + +--connection node_2 +DELETE FROM t1 ORDER BY RAND() LIMIT 5; +--let $sum_remaining = `SELECT SUM(f1) FROM t1` +--let $max_remaining = `SELECT MAX(f1) FROM t1` + +--connection node_1 +--disable_query_log +--eval SELECT (SELECT SUM(f1) FROM t1) = $sum_remaining AS sum_matches; +--eval SELECT f1 = $max_remaining AS max_matches FROM t1 WHERE f1 = $max_remaining; +--enable_query_log + +DROP TABLE t1; + +# +# Without a PK +# + +CREATE TABLE t2 (f1 INTEGER) Engine=InnoDB; +INSERT INTO t2 SELECT f1 FROM ten ORDER BY RAND(); + +--connection node_2 +DELETE FROM t2 ORDER BY RAND() LIMIT 5; +--let $sum_remaining = `SELECT SUM(f1) FROM t2` +--let $max_remaining = `SELECT MAX(f1) FROM t2` + +--connection node_1 +--disable_query_log +--eval SELECT (SELECT SUM(f1) FROM t2) = $sum_remaining AS sum_matches; +--eval SELECT f1 = $max_remaining AS max_matches FROM t2 WHERE f1 = $max_remaining; +--enable_query_log + +DROP TABLE t2; +DROP TABLE ten; diff --git a/mysql-test/suite/galera/t/galera_enum.test b/mysql-test/suite/galera/t/galera_enum.test new file mode 100644 index 00000000000..ff5332486aa --- /dev/null +++ b/mysql-test/suite/galera/t/galera_enum.test @@ -0,0 +1,62 @@ +# +# Test the ENUM column type, as it is frequently an unwanted child +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +# +# ENUM as key +# + +--connection node_1 +CREATE TABLE t1 (f1 ENUM('', 'one', 'two'), KEY (f1)) ENGINE=InnoDB; + +INSERT INTO t1 VALUES (''); +INSERT INTO t1 VALUES ('one'), ('two'); +INSERT INTO t1 VALUES (0), (1), (2); + +--connection node_2 +SELECT COUNT(*) = 6 FROM t1; +SELECT COUNT(*) = 2 FROM t1 where f1 = ''; +SELECT COUNT(*) = 2 FROM t1 where f1 = 'one'; + +DROP TABLE t1; + +# +# ENUM as PK +# + +--connection node_1 +CREATE TABLE t1 (f1 ENUM('', 'one', 'two', 'three', 'four') PRIMARY KEY) ENGINE=InnoDB; + +INSERT INTO t1 VALUES (''), ('one'), ('two'); + +--connection node_2 +SELECT COUNT(*) = 3 FROM t1; +SELECT COUNT(*) = 1 FROM t1 WHERE f1 = ''; + +# Conflict + +--connection node_1 +SET AUTOCOMMIT=OFF; +START TRANSACTION; +UPDATE t1 SET f1 = 'three' where f1 = ''; + +--connection node_2 +SET AUTOCOMMIt=OFF; +START TRANSACTION; +UPDATE t1 SET f1 = 'four' where f1 = ''; + +--connection node_1 +COMMIT; + +--connection node_2 +--error ER_LOCK_DEADLOCK +COMMIT; + +--connection node_1 + +SELECT COUNT(*) = 1 FROM t1 WHERE f1 = 'three'; + +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_events.test b/mysql-test/suite/galera/t/galera_events.test new file mode 100644 index 00000000000..ae9940fc694 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_events.test @@ -0,0 +1,53 @@ +# +# Test that the replication of MySQL events conforms to the behavior of stock MySQL replication as described here +# http://dev.mysql.com/doc/refman/5.6/en/replication-features-invoked.html +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +--let $event_scheduler_orig = `SELECT @@event_scheduler;` + +# +# Events arrive on slave as SLAVESIDE_DISABLED +# + +--connection node_1 +CREATE EVENT event1 ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO SELECT 1; + +--connection node_2 +SELECT DEFINER= 'root@localhost', ORIGINATOR = 1, STATUS = 'SLAVESIDE_DISABLED', EVENT_TYPE = 'ONE TIME', ON_COMPLETION = 'NOT PRESERVE' FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_NAME = 'event1'; + +--connection node_1 +ALTER EVENT event1 DISABLE; + +--connection node_2 +# The definition on node 2 should still say SLAVESIDE_DISABLED +SELECT DEFINER= 'root@localhost', ORIGINATOR = 1, STATUS = 'SLAVESIDE_DISABLED', EVENT_TYPE = 'ONE TIME', ON_COMPLETION = 'NOT PRESERVE' FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_NAME = 'event1'; + +# +# Expired event should be dropped from the slave +# + +--connection node_2 +SET GLOBAL event_scheduler = ON; +CREATE EVENT event2 ON SCHEDULE AT CURRENT_TIMESTAMP ON COMPLETION NOT PRESERVE DO SELECT 1; +--sleep 1 + +--connection node_1 +SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_NAME = 'event2'; + +# +# DROP EVENT causes event to be dropped everywhere +# + +--connection node_1 +DROP EVENT event1; + +--connection node_2 +SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_NAME = 'event1'; + +# Cleanup + +--connection node_2 +--eval SET GLOBAL event_scheduler = $event_scheduler_orig; diff --git a/mysql-test/suite/galera/t/galera_fk_multicolumn.test b/mysql-test/suite/galera/t/galera_fk_multicolumn.test index fc00eadcf5f..ad42f65924d 100644 --- a/mysql-test/suite/galera/t/galera_fk_multicolumn.test +++ b/mysql-test/suite/galera/t/galera_fk_multicolumn.test @@ -8,21 +8,21 @@ CREATE TABLE t0 ( f1 INT PRIMARY KEY, f2 INT UNIQUE -) ENGINE=INNODB; +); CREATE TABLE t1 ( f1 INT PRIMARY KEY, FOREIGN KEY (f1) REFERENCES t0(f1) ON UPDATE CASCADE -) ENGINE=INNODB; +); CREATE TABLE t2 ( f2 INT PRIMARY KEY, FOREIGN KEY (f2) REFERENCES t0(f2) ON UPDATE CASCADE -) ENGINE=INNODB; +); INSERT INTO t0 VALUES (0, 0); INSERT INTO t1 VALUES (0); diff --git a/mysql-test/suite/galera/t/galera_fk_multitable.test b/mysql-test/suite/galera/t/galera_fk_multitable.test index e53757b051b..6adfb8195ec 100644 --- a/mysql-test/suite/galera/t/galera_fk_multitable.test +++ b/mysql-test/suite/galera/t/galera_fk_multitable.test @@ -7,7 +7,7 @@ CREATE TABLE t0 ( f0 INT PRIMARY KEY -) ENGINE=INNODB; +); CREATE TABLE t1 ( f1 INT PRIMARY KEY, @@ -15,7 +15,7 @@ CREATE TABLE t1 ( FOREIGN KEY (f0) REFERENCES t0(f0) ON DELETE CASCADE -) ENGINE=INNODB; +); INSERT INTO t0 VALUES (0), (1); INSERT INTO t1 VALUES (0, 0); diff --git a/mysql-test/suite/galera/t/galera_flush.test b/mysql-test/suite/galera/t/galera_flush.test index 21647a8328c..cd6b40b5b4e 100644 --- a/mysql-test/suite/galera/t/galera_flush.test +++ b/mysql-test/suite/galera/t/galera_flush.test @@ -34,7 +34,7 @@ FLUSH HOSTS; --connection node_1 SET GLOBAL wsrep_replicate_myisam = TRUE; -INSERT INTO mysql.user VALUES('localhost','user1',PASSWORD('pass1'), 'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0,'mysql_native_password','','N'); +INSERT INTO mysql.user VALUES('localhost','user1',PASSWORD('pass1'), 'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0,'mysql_native_password','','N','N'); FLUSH PRIVILEGES; --connect node_2a, 127.0.0.1, user1, pass1, test, $NODE_MYPORT_2 --connection node_1 diff --git a/mysql-test/suite/galera/t/galera_ftwrl.test b/mysql-test/suite/galera/t/galera_ftwrl.test new file mode 100644 index 00000000000..db9bd132566 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_ftwrl.test @@ -0,0 +1,39 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc + +# +# At this time, issing a FLUSH TABLES WITH READ LOCK causes SELECT and SHOW to hang if +# casuality can not be ensured because another node issued a statement in the meantime +# which could not be applied because FTWRL blocks the applier as well +# +# See LP bug 1271177 +# + +CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB; + +--connection node_2 +--let $wsrep_provider_options_orig = `SELECT @@wsrep_provider_options;` +SET GLOBAL wsrep_provider_options = "repl.causal_read_timeout=PT1S"; +FLUSH TABLES WITH READ LOCK; + +--connection node_1 +INSERT INTO t1 VALUES (1); + +--connection node_2 +--error ER_LOCK_WAIT_TIMEOUT +SHOW TABLES; + +--error ER_LOCK_WAIT_TIMEOUT +SELECT * FROM t1; + +UNLOCK TABLES; + +SHOW TABLES; +SELECT COUNT(*) = 1 FROM t1; + +--disable_query_log +--eval SET GLOBAL wsrep_provider_options = "$wsrep_provider_options_orig"; +--enable_query_log + +DROP TABLE t1; + diff --git a/mysql-test/suite/galera/t/galera_fulltext.test b/mysql-test/suite/galera/t/galera_fulltext.test new file mode 100644 index 00000000000..aa93a336f92 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_fulltext.test @@ -0,0 +1,62 @@ +--source include/big_test.inc +--source include/galera_cluster.inc +--source include/have_innodb.inc + +# +# InnoDB FULLTEXT indexes +# + +CREATE TABLE ten (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); + +# +# Fulltext index creation causes the creation of multiple system tables +# + +--connection node_1 +CREATE TABLE t1 (f1 INT PRIMARY KEY AUTO_INCREMENT, f2 VARCHAR(100), FULLTEXT (f2)) ENGINE=InnoDB; + +--connection node_2 +SELECT COUNT(*) = 13 FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE name LIKE 'test/%'; + +# +# Fulltext insertion causes a flurry of updates on those system tables +# + +--connection node_1 +# Insert 10K rows +INSERT INTO t1 (f2) SELECT 'foobarbaz' FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4; + +--connection node_2 +SELECT COUNT(f2) = 10000 FROM t1 WHERE MATCH(f2) AGAINST ('foobarbaz'); + +UPDATE t1 SET f2 = 'abcdefjhk'; + +--connection node_1 +SELECT COUNT(f2) = 10000 FROM t1 WHERE MATCH(f2) AGAINST ('abcdefjhk'); + +--connection node_2 + +DROP TABLE t1; + +# +# Same on a table with no PK +# + +--connection node_1 +CREATE TABLE t1 (f1 VARCHAR(100), FULLTEXT (f1)) ENGINE=InnoDB; + +--connection node_2 +# We insert only 1K rows here, because updates without a PK are very slow +INSERT INTO t1 (f1) SELECT 'foobarbaz' FROM ten AS a1, ten AS a2, ten AS a3; + +--connection node_1 +SELECT COUNT(f1) = 1000 FROM t1 WHERE MATCH(f1) AGAINST ('foobarbaz'); + +UPDATE t1 SET f1 = 'abcdefjhk'; + +--connection node_2 +SELECT COUNT(f1) = 1000 FROM t1 WHERE MATCH(f1) AGAINST ('abcdefjhk'); + +DROP TABLE t1; +DROP TABLE ten; diff --git a/mysql-test/suite/galera/t/galera_gcs_fc_limit.test b/mysql-test/suite/galera/t/galera_gcs_fc_limit.test new file mode 100644 index 00000000000..e15da0e35ad --- /dev/null +++ b/mysql-test/suite/galera/t/galera_gcs_fc_limit.test @@ -0,0 +1,52 @@ +# +# Test that under gcs.fc_limit=1 on the slave, transactions on the master can not commit. +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); + +--connection node_2 +--let $wsrep_provider_options_orig = `SELECT @@wsrep_provider_options` +SET GLOBAL wsrep_provider_options = 'gcs.fc_limit=1'; + +# Block the slave applier thread +FLUSH TABLES WITH READ LOCK; + +--connection node_1 + +INSERT INTO t1 VALUES (2); +INSERT INTO t1 VALUES (3); +INSERT INTO t1 VALUES (4); + +# This query will hang because flow control will kick in +--send +INSERT INTO t1 VALUES (5); +--sleep 1 + +--let $galera_connection_name = node_1a +--let $galera_server_number = 1 +--source include/galera_connect.inc +--connection node_1a +SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = 'query end' AND INFO = 'INSERT INTO t1 VALUES (5)'; + +--connection node_2 +# Unblock the slave applier thread +UNLOCK TABLES; + +--connection node_1 +--reap + +INSERT INTO t1 VALUES (6); + +--connection node_2 +# Replication catches up and continues normally +SELECT COUNT(*) = 6 FROM t1; + +--disable_query_log +--eval SET GLOBAL wsrep_provider_options = '$wsrep_provider_options_orig'; +--enable_query_log + +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_gcs_max_packet_size.cnf b/mysql-test/suite/galera/t/galera_gcs_max_packet_size.cnf new file mode 100644 index 00000000000..aae3fee5904 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_gcs_max_packet_size.cnf @@ -0,0 +1,5 @@ +!include ../galera_2nodes.cnf +[mysqld.1] +wsrep_provider_options='base_port=@mysqld.1.#galera_port;gcs.max_packet_size=64' +[mysqld.2] +wsrep_provider_options='base_port=@mysqld.2.#galera_port;gcs.max_packet_size=64' diff --git a/mysql-test/suite/galera/t/galera_gcs_max_packet_size.test b/mysql-test/suite/galera/t/galera_gcs_max_packet_size.test new file mode 100644 index 00000000000..cafd8acfdd9 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_gcs_max_packet_size.test @@ -0,0 +1,25 @@ +# +# Test fragmentation by setting gcs.max_packet_size to a low value +# The actual setting is performed in galera_gcs_max_packet_size.cnf +# as gcs.max_packet_size is not a dynamic variable +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +CREATE TABLE ten (f1 INTEGER); +INSERT INTO ten VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); + +CREATE TABLE t1 (f1 INT PRIMARY KEY AUTO_INCREMENT, f2 INTEGER) ENGINE=InnoDB; +CREATE TABLE t2 (f1 VARCHAR(512) UNIQUE) ENGINE=InnoDB; + +INSERT INTO t1 (f2) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4; +INSERT INTO t2 VALUES (REPEAT('x', 512)); + +--connection node_2 +SELECT COUNT(*) = 10000 FROM t1; +SELECT LENGTH(f1) = 512 FROM t2 WHERE f1 = REPEAT('x', 512); + +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE ten; diff --git a/mysql-test/suite/galera/t/galera_gtid-master.opt b/mysql-test/suite/galera/t/galera_gtid-master.opt new file mode 100644 index 00000000000..8a755e98b00 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_gtid-master.opt @@ -0,0 +1 @@ +--log-bin --log-slave-updates diff --git a/mysql-test/suite/galera/t/galera_gtid.test b/mysql-test/suite/galera/t/galera_gtid.test new file mode 100644 index 00000000000..e8369be62e6 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_gtid.test @@ -0,0 +1,27 @@ +# +# Test GTID for basic Galera operations +# + +--source include/have_log_bin.inc +--source include/galera_cluster.inc +--source include/have_innodb.inc + +CREATE TABLE t1 (f1 INT PRIMARY KEY); + +INSERT INTO t1 VALUES (1); + +--connection node_2 +SELECT COUNT(*) = 1 FROM t1; + +UPDATE t1 SET f1 = 2; + +--let $gtid_binlog_state_node2 = `SELECT @@global.gtid_binlog_state;` + +--connection node_1 +SELECT COUNT(*) = 1 FROM t1 WHERE f1 = 2; + +--disable_query_log +--eval SELECT '$gtid_binlog_state_node2' = @@global.gtid_binlog_state AS gtid_binlog_state_equal; +--enable_query_log + +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_insert_ignore.test b/mysql-test/suite/galera/t/galera_insert_ignore.test new file mode 100644 index 00000000000..4b4b0a6e9fb --- /dev/null +++ b/mysql-test/suite/galera/t/galera_insert_ignore.test @@ -0,0 +1,60 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc + +--let $wsrep_sync_wait_orig = (SELECT @@wsrep_sync_wait) +SET GLOBAL wsrep_sync_wait = 7; + +--connection node_2 +SET GLOBAL wsrep_sync_wait = 7; + + +# +# INSERT IGNORE with PRIMARY KEY +# + +--connection node_1 +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); + +INSERT IGNORE INTO t1 VALUES (1), (2); +SELECT * FROM t1; + +--connection node_2 +SELECT * FROM t1; + +# +# INSERT IGNORE ... SELECT +# + +--connection node_2 +CREATE TABLE t2 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t2 VALUES (0), (2), (3); +INSERT IGNORE INTO t1 SELECT f1 FROM t2; + +SELECT * FROM t1; +--connection node_1 +SELECT * FROM t1; + +# +# INSERT IGNORE with UNIQUE + NULLs +# + +--connection node_2 +CREATE TABLE t3 (f1 INTEGER UNIQUE) Engine=InnoDB; +INSERT INTO t3 VALUES (NULL); + +--connection node_1 +INSERT IGNORE INTO t3 VALUES (1), (NULL), (2); +SELECT * FROM t3; + +--connection node_2 +SELECT * FROM t3; + +--eval SET GLOBAL wsrep_sync_wait = $wsrep_sync_wait_orig + +--connection node_1 +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE t3; +--eval SET GLOBAL wsrep_sync_wait = $wsrep_sync_wait_orig + diff --git a/mysql-test/suite/galera/t/galera_insert_multi.test b/mysql-test/suite/galera/t/galera_insert_multi.test new file mode 100644 index 00000000000..d62283aff69 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_insert_multi.test @@ -0,0 +1,122 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc + +# +# Multi-row INSERT with a PK +# + +--connection node_1 +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1),(2); + +--connection node_2 +INSERT INTO t1 VALUES (3),(4); + +--connection node_1 +SELECT COUNT(*) = 4 FROM t1; + +--connection node_2 +SELECT COUNT(*) = 4 FROM t1; + +DROP TABLE t1; + +# +# Multi-row INSERT without a PK +# + +--connection node_2 +CREATE TABLE t1 (f1 INTEGER, KEY (f1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1),(1); + +--connection node_1 +INSERT INTO t1 VALUES (2),(2); + +--connection node_2 +SELECT COUNT(*) = 4 FROM t1; + +--connection node_1 +SELECT COUNT(*) = 4 FROM t1; + +DROP TABLE t1; + +# +# Error in the middle of a multi-row INSERT +# + +--connection node_1 +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; + +--error ER_DUP_ENTRY +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (1); + +SELECT COUNT(*) = 0 FROM t1; + +--connection node_2 +SELECT COUNT(*) = 0 FROM t1; + +DROP TABLE t1; + +# +# Deadlock +# + +--connection node_1 +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; + +SET AUTOCOMMIT = OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (1), (2); + +--connection node_2 +SET AUTOCOMMIT = OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (2), (1); + +--connection node_1 +COMMIT; + +--connection node_2 +--error ER_LOCK_DEADLOCK +COMMIT; + +# Workaround for mysql-wsrep#39 Transaction receives deadlock error twice in row +--error 0,ER_LOCK_DEADLOCK +ROLLBACK; + +--error ER_DUP_ENTRY +INSERT INTO t1 VALUES (1), (2); + +DROP TABLE t1; + +# +# Rollback +# + +--connection node_1 +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; + +START TRANSACTION; +INSERT INTO t1 VALUES (1), (2); + +--connection node_2 +START TRANSACTION; +INSERT INTO t1 VALUES (2), (1); + +--connection node_1 +ROLLBACK; + +--connection node_2 +COMMIT; +SELECT COUNT(*) = 2 FROM t1; + +--connection node_1 +SELECT COUNT(*) = 2 FROM t1; + +DROP TABLE t1; + + + + + + + diff --git a/mysql-test/suite/galera/t/galera_ist_innodb_flush_logs.cnf b/mysql-test/suite/galera/t/galera_ist_innodb_flush_logs.cnf new file mode 100644 index 00000000000..85245ff464a --- /dev/null +++ b/mysql-test/suite/galera/t/galera_ist_innodb_flush_logs.cnf @@ -0,0 +1,12 @@ +!include ../galera_2nodes.cnf + +[mysqld] +wsrep_sst_method=xtrabackup-v2 +innodb_flush_log_at_trx_commit=0 + +[mysqld.1] +wsrep_provider_options='base_port=@mysqld.1.#galera_port;pc.ignore_sb=true' + +[mysqld.2] +wsrep_provider_options='base_port=@mysqld.2.#galera_port;pc.ignore_sb=true' + diff --git a/mysql-test/suite/galera/t/galera_ist_innodb_flush_logs.test b/mysql-test/suite/galera/t/galera_ist_innodb_flush_logs.test new file mode 100644 index 00000000000..07838702deb --- /dev/null +++ b/mysql-test/suite/galera/t/galera_ist_innodb_flush_logs.test @@ -0,0 +1,12 @@ +# +# This test performs server kill and IST while innodb_flush_logs_on_trx_commit = 0 +# This confirms that IST can properly catch up even in the face of relaxed single-node durability +# +# + +--source include/big_test.inc +--source include/galera_cluster.inc +--source include/have_innodb.inc + +--source suite/galera/include/galera_st_kill_slave.inc +--source suite/galera/include/galera_st_kill_slave_ddl.inc diff --git a/mysql-test/suite/galera/t/galera_ist_mysqldump.cnf b/mysql-test/suite/galera/t/galera_ist_mysqldump.cnf new file mode 100644 index 00000000000..db6b7d5e129 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_ist_mysqldump.cnf @@ -0,0 +1,11 @@ +!include ../galera_2nodes.cnf + +# We do not set mysqldump-related SST options here because doing so on startup +# causes the first MTR connection to be forefully dropped by Galera, which in turn confuses MTR + +[mysqld.1] +wsrep_provider_options='base_port=@mysqld.1.#galera_port;pc.ignore_sb=true' + +[mysqld.2] +wsrep_provider_options='base_port=@mysqld.2.#galera_port;pc.ignore_sb=true' + diff --git a/mysql-test/suite/galera/t/galera_ist_mysqldump.test b/mysql-test/suite/galera/t/galera_ist_mysqldump.test new file mode 100644 index 00000000000..a9ff8c41f06 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_ist_mysqldump.test @@ -0,0 +1,17 @@ +--source include/big_test.inc +--source include/galera_cluster.inc +--source include/have_innodb.inc + +--source suite/galera/include/galera_sst_set_mysqldump.inc + +# mysql-wsrep#33 - nnoDB: Failing assertion: xid_seqno > trx_sys_cur_xid_seqno in trx_sys_update_wsrep_checkpoint with mysqldump IST +# --source suite/galera/include/galera_st_disconnect_slave.inc + +# We set the required mysqldump SST options here so that they are used every time the server is restarted during the test +--let $start_mysqld_params = --wsrep_sst_auth=sst:sst --wsrep_sst_method=mysqldump --wsrep-sst-receive-address=127.0.0.1:$NODE_MYPORT_2 --skip-grant-tables + +--source suite/galera/include/galera_st_shutdown_slave.inc +--source suite/galera/include/galera_st_kill_slave.inc +--source suite/galera/include/galera_st_kill_slave_ddl.inc + +--source suite/galera/include/galera_sst_restore.inc diff --git a/mysql-test/suite/galera/t/galera_ist_restart_joiner.cnf b/mysql-test/suite/galera/t/galera_ist_restart_joiner.cnf new file mode 100644 index 00000000000..10958aad9a8 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_ist_restart_joiner.cnf @@ -0,0 +1,4 @@ +!include ../galera_2nodes.cnf + +[mysqld.1] +wsrep_provider_options='base_port=@mysqld.1.#galera_port;pc.ignore_sb=true' diff --git a/mysql-test/suite/galera/t/galera_ist_restart_joiner.test b/mysql-test/suite/galera/t/galera_ist_restart_joiner.test new file mode 100644 index 00000000000..69446f0f86a --- /dev/null +++ b/mysql-test/suite/galera/t/galera_ist_restart_joiner.test @@ -0,0 +1,106 @@ +# +# Test that a joiner performing IST can be killed and restarted with no adverse consequences. +# This is achieved by using the recv_IST_after_apply_trx Galera dbug sync point to block IST after +# one transaction has been applied. When IST blocks, we kill and restart the joiner +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc +--source include/have_debug_sync.inc +--source suite/galera/include/galera_have_debug_sync.inc + +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 CHAR(1)); +INSERT INTO t1 VALUES (1, 'a'), (2, 'a'), (3, 'a'), (4, 'a'), (5, 'a'),(6, 'a'); + +# Disconnect node #2 +--connection node_2 +--source suite/galera/include/galera_unload_provider.inc + +--connection node_1 +UPDATE t1 SET f2 = 'b' WHERE f1 > 1; + +# Wait until node #1 has left +--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' +--source include/wait_condition.inc + +UPDATE t1 SET f2 = 'c' WHERE f1 > 2; + +--connection node_2 +# Make sure IST will block ... +SET GLOBAL wsrep_provider_options = 'dbug=d,recv_IST_after_apply_trx'; +SET SESSION wsrep_sync_wait = 0; + + +# Write file to make mysql-test-run.pl expect the crash, but don't start it +--let $_server_id= `SELECT @@server_id` +--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.$_server_id.expect +--exec echo "wait" > $_expect_file_name + +--let KILL_NODE_PIDFILE = `SELECT @@pid_file` + +# ... and restart provider to force IST +--echo Loading wsrep_provider ... +--disable_query_log +--eval SET GLOBAL wsrep_provider = '$wsrep_provider_orig'; +--eval SET GLOBAL wsrep_cluster_address = '$wsrep_cluster_address_orig'; +--enable_query_log + +# We can not use a wait_condition on SELECT * FROM INFORMATION_SCHEMA.GLOBAL_STATUS as such queries are blocked during IST +# so we perform a simple sleep and SHOW instead + +--sleep 5 +SHOW STATUS LIKE 'wsrep_debug_sync_waiters'; + +--connection node_1 +# Perform DML and DDL while IST is in progress +--connection node_1 +UPDATE t1 SET f2 = 'd' WHERE f1 > 3; +CREATE TABLE t2 (f1 INTEGER); + +# Kill node #2 while IST is in progress +--connection node_2 + +# Kill the connected server +--disable_reconnect + +--perl + my $pid_filename = $ENV{'KILL_NODE_PIDFILE'}; + my $mysqld_pid = `cat $pid_filename`; + chomp($mysqld_pid); + system("kill -9 $mysqld_pid"); + exit(0); +EOF + +--source include/wait_until_disconnected.inc + +--connection node_1 +--source include/wait_until_connected_again.inc +--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' +--source include/wait_condition.inc + +# Perform DML and DDL while node #2 is down +UPDATE t1 SET f2 = 'e' WHERE f1 > 4; +CREATE TABLE t3 (f1 INTEGER); + +--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 + +--connection node_1 +UPDATE t1 SET f2 = 'f' WHERE f1 > 5; +SELECT * FROM t1; + +--connection node_2 +SELECT * FROM t1; +SELECT COUNT(*) = 0 FROM t2; +SELECT COUNT(*) = 0 FROM t3; + +--connection node_1 +DROP TABLE t1, t2, t3; diff --git a/mysql-test/suite/galera/t/galera_ist_rsync.cnf b/mysql-test/suite/galera/t/galera_ist_rsync.cnf new file mode 100644 index 00000000000..bbe0f6047fb --- /dev/null +++ b/mysql-test/suite/galera/t/galera_ist_rsync.cnf @@ -0,0 +1,11 @@ +!include ../galera_2nodes.cnf + +[mysqld] +wsrep_sst_method=rsync + +[mysqld.1] +wsrep_provider_options='base_port=@mysqld.1.#galera_port;pc.ignore_sb=true' + +[mysqld.2] +wsrep_provider_options='base_port=@mysqld.2.#galera_port;pc.ignore_sb=true' + diff --git a/mysql-test/suite/galera/t/galera_ist_rsync.test b/mysql-test/suite/galera/t/galera_ist_rsync.test new file mode 100644 index 00000000000..41d1a0c1fc2 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_ist_rsync.test @@ -0,0 +1,8 @@ +--source include/big_test.inc +--source include/galera_cluster.inc +--source include/have_innodb.inc + +--source suite/galera/include/galera_st_disconnect_slave.inc +--source suite/galera/include/galera_st_shutdown_slave.inc +--source suite/galera/include/galera_st_kill_slave.inc +--source suite/galera/include/galera_st_kill_slave_ddl.inc diff --git a/mysql-test/suite/galera/t/galera_ist_xtrabackup-v2.cnf b/mysql-test/suite/galera/t/galera_ist_xtrabackup-v2.cnf new file mode 100644 index 00000000000..21e597445a8 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_ist_xtrabackup-v2.cnf @@ -0,0 +1,11 @@ +!include ../galera_2nodes.cnf + +[mysqld] +wsrep_sst_method=xtrabackup-v2 + +[mysqld.1] +wsrep_provider_options='base_port=@mysqld.1.#galera_port;pc.ignore_sb=true' + +[mysqld.2] +wsrep_provider_options='base_port=@mysqld.2.#galera_port;pc.ignore_sb=true' + diff --git a/mysql-test/suite/galera/t/galera_ist_xtrabackup-v2.test b/mysql-test/suite/galera/t/galera_ist_xtrabackup-v2.test new file mode 100644 index 00000000000..8b399e77794 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_ist_xtrabackup-v2.test @@ -0,0 +1,9 @@ +--source include/big_test.inc +--source include/galera_cluster.inc +--source include/have_innodb.inc + +--source suite/galera/include/galera_st_disconnect_slave.inc +--source suite/galera/include/galera_st_shutdown_slave.inc + +--source suite/galera/include/galera_st_kill_slave.inc +--source suite/galera/include/galera_st_kill_slave_ddl.inc diff --git a/mysql-test/suite/galera/t/galera_kill_ddl.test b/mysql-test/suite/galera/t/galera_kill_ddl.test new file mode 100644 index 00000000000..3c2bce5b9c9 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_kill_ddl.test @@ -0,0 +1,39 @@ +# +# This test kill -9-s a slave while small updates have been performed on the master. +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +--connection node_1 + +# Enable the master to continue running during the split-brain situation that +# occurs when the slave is killed +--let $wsrep_provider_options_orig = `SELECT @@wsrep_provider_options` +SET GLOBAL wsrep_provider_options = 'pc.ignore_sb=true'; + +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; + +--connection node_2 +--source include/kill_galera.inc + +--connection node_1 +ALTER TABLE t1 ADD COLUMN f2 INTEGER; + +--connection node_2 +--source include/start_mysqld.inc + +--let $galera_connection_name = node_2a +--let $galera_server_number = 2 +--source include/galera_connect.inc +--connection node_2a + +SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='t1'; +SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; + +--connection node_1 +--disable_query_log +--eval SET GLOBAL wsrep_provider_options = '$wsrep_provider_options_orig'; +--enable_query_log + +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_kill_largechanges.test b/mysql-test/suite/galera/t/galera_kill_largechanges.test new file mode 100644 index 00000000000..e9a32ce813b --- /dev/null +++ b/mysql-test/suite/galera/t/galera_kill_largechanges.test @@ -0,0 +1,43 @@ +# +# This test kill -9-s a slave while a large update has been performed on the master. SST is performed. +# + +--source include/big_test.inc +--source include/galera_cluster.inc +--source include/have_innodb.inc + +--connection node_1 +# Enable the master to continue running during the split-brain situation that +# occurs when the slave is killed +--let $wsrep_provider_options_orig = `SELECT @@wsrep_provider_options` +SET GLOBAL wsrep_provider_options = 'pc.ignore_sb=true'; + +CREATE TABLE ten (f1 INTEGER); +INSERT INTO ten VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t1 (f1 VARCHAR(128)) ENGINE=InnoDB; + +--connection node_2 +--source include/kill_galera.inc + +--connection node_1 +# We create a 128Mb (or so) transaction that is larger than gcache. The size of the gcache is not adjustable dynamically +INSERT INTO t1 SELECT REPEAT('a', 128) FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5, ten AS a6; + +--connection node_2 +--source include/start_mysqld.inc + +--let $galera_connection_name = node_2a +--let $galera_server_number = 2 +--source include/galera_connect.inc +--connection node_2a + +SELECT COUNT(*) = 1000000 FROM t1; +SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; + +--connection node_1 +--disable_query_log +--eval SET GLOBAL wsrep_provider_options = '$wsrep_provider_options_orig'; +--enable_query_log + +DROP TABLE t1; +DROP TABLE ten; diff --git a/mysql-test/suite/galera/t/galera_kill_nochanges.test b/mysql-test/suite/galera/t/galera_kill_nochanges.test new file mode 100644 index 00000000000..1903df449e4 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_kill_nochanges.test @@ -0,0 +1,24 @@ +# +# This test kill -9-s a slave while no updates have been performed on the master. +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +--connection node_1 +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); + +--connection node_2 +--source include/kill_galera.inc +--source include/start_mysqld.inc + +--let $galera_connection_name = node_2a +--let $galera_server_number = 2 +--source include/galera_connect.inc +--connection node_2a + +SELECT COUNT(*) = 1 FROM t1; +SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; + +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_kill_smallchanges.test b/mysql-test/suite/galera/t/galera_kill_smallchanges.test new file mode 100644 index 00000000000..d998032cbc3 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_kill_smallchanges.test @@ -0,0 +1,39 @@ +# +# This test kill -9-s a slave while small updates have been performed on the master. +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +--connection node_1 + +# Enable the master to continue running during the split-brain situation that +# occurs when the slave is killed +--let $wsrep_provider_options_orig = `SELECT @@wsrep_provider_options` +SET GLOBAL wsrep_provider_options = 'pc.ignore_sb=true'; + +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; + +--connection node_2 +--source include/kill_galera.inc + +--connection node_1 +INSERT INTO t1 VALUES (1); + +--connection node_2 +--source include/start_mysqld.inc + +--let $galera_connection_name = node_2a +--let $galera_server_number = 2 +--source include/galera_connect.inc +--connection node_2a + +SELECT COUNT(*) = 1 FROM t1; +SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; + +--connection node_1 +--disable_query_log +--eval SET GLOBAL wsrep_provider_options = '$wsrep_provider_options_orig'; +--enable_query_log + +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_lock_table.test b/mysql-test/suite/galera/t/galera_lock_table.test new file mode 100644 index 00000000000..bd581842f6f --- /dev/null +++ b/mysql-test/suite/galera/t/galera_lock_table.test @@ -0,0 +1,43 @@ +# +# Test that a LOCK TABLE on the slave will cause the applier thread to block, so no subsequent updates +# are replicated on the slave until UNLOCK TABLE is issued. +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +--let $wsrep_sync_wait_orig = `SELECT @@wsrep_sync_wait` + +CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB; +CREATE TABLE t2 (id INT PRIMARY KEY) ENGINE=InnoDB; + +--connection node_2 +LOCK TABLE t1 READ; + +--connection node_1 +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1); + +# We use a separate connection here so that we can SELECT from both tables +# without running into "table t2 was not locked" error. + +--let $galera_connection_name = node_2a +--let $galera_server_number = 2 +--source include/galera_connect.inc +--connection node_2a +SET SESSION wsrep_sync_wait=0; +SELECT COUNT(*) = 0 FROM t1; +SELECT COUNT(*) = 0 FROM t2; + +--connection node_2 +UNLOCK TABLES; + +--disable_query_log +--eval SET SESSION wsrep_sync_wait=$wsrep_sync_wait_orig; +--enable_query_log + +SELECT COUNT(*) = 1 FROM t1; +SELECT COUNT(*) = 1 FROM t2; + +DROP TABLE t1; +DROP TABLE t2; diff --git a/mysql-test/suite/galera/t/galera_log_bin-master.opt b/mysql-test/suite/galera/t/galera_log_bin-master.opt new file mode 100644 index 00000000000..8a755e98b00 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_log_bin-master.opt @@ -0,0 +1 @@ +--log-bin --log-slave-updates diff --git a/mysql-test/suite/galera/t/galera_log_bin.test b/mysql-test/suite/galera/t/galera_log_bin.test new file mode 100644 index 00000000000..7d592d63ee3 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_log_bin.test @@ -0,0 +1,36 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc + +# +# Test Galera with --log-bin --log-slave-updates . +# This way the actual MySQL binary log is used, +# rather than Galera's own implementation +# + +CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); + +CREATE TABLE t2 (id INT) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1); +INSERT INTO t2 VALUES (1); + +--connection node_2 +SELECT COUNT(*) = 1 FROM t1; +SELECT COUNT(*) = 2 FROM t2; + +--connection node_1 +ALTER TABLE t1 ADD COLUMN f2 INTEGER; + +FLUSH LOGS; +# Use pos 120 in order to skip the header that contains the MySQL version number. +# Otherwise, version number changes will cause the test to break +SHOW BINLOG EVENTS IN 'mysqld-bin.000002' LIMIT 4,18; + +--connection node_2 +SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; + +SHOW BINLOG EVENTS IN 'mysqld-bin.000003' LIMIT 3,19; + +DROP TABLE t1; +DROP TABLE t2; + diff --git a/mysql-test/suite/galera/t/galera_log_output_csv-master.opt b/mysql-test/suite/galera/t/galera_log_output_csv-master.opt new file mode 100644 index 00000000000..2f71b140b65 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_log_output_csv-master.opt @@ -0,0 +1 @@ +--log-output=TABLE --log-queries-not-using-indexes --general-log --slow-query-log diff --git a/mysql-test/suite/galera/t/galera_log_output_csv.test b/mysql-test/suite/galera/t/galera_log_output_csv.test new file mode 100644 index 00000000000..00009396f6a --- /dev/null +++ b/mysql-test/suite/galera/t/galera_log_output_csv.test @@ -0,0 +1,27 @@ +# +# Test that --log-output=FILE works with Galera. +# The relevant options are set using a -master.opt file +# wsrep_replicate_myisam is not used as it crashes in MTR with mysql-wsrep#14 +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); + +SELECT COUNT(*) > 0 FROM mysql.general_log; + +SELECT 1 = 1 FROM t1; +SELECT COUNT(*) = 1 FROM mysql.slow_log WHERE sql_text = 'SELECT 1 = 1 FROM t1'; + +--connection node_2 + +# CREATE TABLE from master is also present in the slave query log, but is logged twice, mysql-wsrep#44 +SELECT COUNT(*) > 0 FROM mysql.general_log WHERE argument = 'CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB'; + +SELECT 2 = 2 FROM t1; +SELECT COUNT(*) = 1 FROM mysql.slow_log WHERE sql_text = 'SELECT 2 = 2 FROM t1'; + +--connection node_1 +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_many_columns.test b/mysql-test/suite/galera/t/galera_many_columns.test index 09bd9902e81..3f596179c01 100644 --- a/mysql-test/suite/galera/t/galera_many_columns.test +++ b/mysql-test/suite/galera/t/galera_many_columns.test @@ -2,20 +2,18 @@ --source include/galera_cluster.inc --source include/have_innodb.inc -CREATE TABLE t1 (f1017 VARCHAR(3) DEFAULT 'ABC') ENGINE=InnoDB; - ---let $count = 1016 +--disable_query_log +SET @create_var1 = ""; +--let $count = 1017 while ($count) { - --disable_query_log - --eval SET @ddl_var1 = CONCAT("ALTER TABLE t1 ADD COLUMN f", $count, " VARCHAR(3) DEFAULT 'ABC'") - --let $ddl_var = `SELECT @ddl_var1` - --enable_query_log - --eval $ddl_var + --eval SET @create_var1 = CONCAT(@create_var1, "f", $count, " VARCHAR(3) DEFAULT 'ABC', ") --dec $count } -ALTER TABLE t1 ADD PRIMARY KEY (f1, f1017); +--let $create_var = `SELECT @create_var1` +--eval CREATE TABLE t1 ($create_var PRIMARY KEY (f1, f1017)) ENGINE=InnoDB; +--enable_query_log INSERT INTO t1 (f1) VALUES (DEFAULT); diff --git a/mysql-test/suite/galera/t/galera_many_rows.test b/mysql-test/suite/galera/t/galera_many_rows.test index 5ec1af0a8bf..0f4c4c0db78 100644 --- a/mysql-test/suite/galera/t/galera_many_rows.test +++ b/mysql-test/suite/galera/t/galera_many_rows.test @@ -3,7 +3,7 @@ --source include/galera_cluster.inc --source include/have_innodb.inc -CREATE TABLE ten (f1 INTEGER) ENGINE=INNODB; +CREATE TABLE ten (f1 INTEGER); INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); CREATE TABLE t1 (f1 INTEGER AUTO_INCREMENT PRIMARY KEY, f2 INTEGER) Engine=InnoDB; diff --git a/mysql-test/suite/galera/t/galera_many_tables_nopk.test b/mysql-test/suite/galera/t/galera_many_tables_nopk.test new file mode 100644 index 00000000000..2496d145c93 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_many_tables_nopk.test @@ -0,0 +1,103 @@ +--source include/big_test.inc +--source include/galera_cluster.inc +--source include/have_innodb.inc + +# +# This test forces 1K tables without a PK to participate in a single transaction +# + +# +# First, create 1K tables +# + +--connection node_1 + +--let $count = 1000 +while ($count) +{ + --disable_query_log + --let $ddl_var = `SELECT CONCAT("CREATE TABLE t", $count, " (f1 INTEGER) ENGINE=InnoDB")` + --eval $ddl_var + --enable_query_log + --dec $count +} + +--let $count = 1000 +while ($count) +{ + --disable_query_log + --let $ddl_var = `SELECT CONCAT("INSERT INTO t", $count, " VALUES (1234)")` + --eval $ddl_var + --enable_query_log + --dec $count +} + +# +# Second, perform 1K updates +# + +SET AUTOCOMMIT=OFF; +START TRANSACTION; + +--let $count = 1000 +while ($count) +{ + --disable_query_log + --let $ddl_var = `SELECT CONCAT("UPDATE t", $count, " SET f1 = 1")` + --eval $ddl_var + --enable_query_log + --dec $count +} + +COMMIT; + +# Third, confirm that all the inserts have arrived on the second node +# + +--connection node_2 +CREATE TABLE sum_table (f1 INTEGER); + +--let $count = 1000 +while ($count) +{ + --disable_query_log + --let $ddl_var = `SELECT CONCAT("INSERT INTO sum_table SELECT COUNT(*) FROM t", $count)` + --eval $ddl_var + --enable_query_log + --dec $count +} + +SELECT SUM(f1) = 1000 FROM sum_table; + +# +# Fourth, create a deadlock +# + +--connection node_1 +SET AUTOCOMMIT=OFF; +START TRANSACTION; + +--let $count = 1000 +while ($count) +{ + --disable_query_log + --let $ddl_var = `SELECT CONCAT("UPDATE t", $count, " SET f1 = 2")` + --eval $ddl_var + --enable_query_log + --dec $count +} + +--connection node_2 +SET AUTOCOMMIT=OFF; +START TRANSACTION; +UPDATE t1000 SET f1 = 3; + +--connection node_1 +COMMIT; + +--connection node_2 +--error ER_LOCK_DEADLOCK +COMMIT; + +DROP SCHEMA test; +CREATE SCHEMA test; diff --git a/mysql-test/suite/galera/t/galera_many_tables_pk.test b/mysql-test/suite/galera/t/galera_many_tables_pk.test new file mode 100644 index 00000000000..886cb7c1a00 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_many_tables_pk.test @@ -0,0 +1,98 @@ +--source include/big_test.inc +--source include/galera_cluster.inc +--source include/have_innodb.inc + +# +# This test forces 1K tables with a PK to participate in a single transaction +# + +# +# First, create 1K tables and make sure the DDLs are all propagated +# + +--connection node_1 + +--let $count = 1000 +while ($count) +{ + --disable_query_log + --let $ddl_var = `SELECT CONCAT("CREATE TABLE t", $count, " (f1 INTEGER AUTO_INCREMENT PRIMARY KEY) ENGINE=InnoDB")` + --eval $ddl_var + --enable_query_log + --dec $count +} + +--connection node_2 +SELECT COUNT(*) = 1000 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME LIKE 't%'; + +# +# Second, create a transaction that uses all those tables +# + +--connection node_1 +SET AUTOCOMMIT=OFF; +START TRANSACTION; + +--let $count = 1000 +while ($count) +{ + --disable_query_log + --let $ddl_var = `SELECT CONCAT("INSERT INTO t", $count, " VALUES (DEFAULT)")` + --eval $ddl_var + --enable_query_log + --dec $count +} + +COMMIT; + +# +# Third, confirm that all the inserts have arrived on the second node +# + +--connection node_2 +CREATE TABLE sum_table (f1 INTEGER); + +--let $count = 1000 +while ($count) +{ + --disable_query_log + --let $ddl_var = `SELECT CONCAT("INSERT INTO sum_table SELECT COUNT(*) FROM t", $count)` + --eval $ddl_var + --enable_query_log + --dec $count +} + +SELECT SUM(f1) = 1000 FROM sum_table; + +# +# Fourth, create a deadlock +# + +--connection node_1 +SET AUTOCOMMIT=OFF; +START TRANSACTION; + +--let $count = 1000 +while ($count) +{ + --disable_query_log + --let $ddl_var = `SELECT CONCAT("UPDATE t", $count, " SET f1 = 2")` + --eval $ddl_var + --enable_query_log + --dec $count +} + +--connection node_2 +SET AUTOCOMMIT=OFF; +START TRANSACTION; +UPDATE t1000 SET f1 = 3; + +--connection node_1 +COMMIT; + +--connection node_2 +--error ER_LOCK_DEADLOCK +COMMIT; + +DROP SCHEMA test; +CREATE SCHEMA test; diff --git a/mysql-test/suite/galera/t/galera_migrate.cnf b/mysql-test/suite/galera/t/galera_migrate.cnf new file mode 100644 index 00000000000..47bdf53afef --- /dev/null +++ b/mysql-test/suite/galera/t/galera_migrate.cnf @@ -0,0 +1,59 @@ +# +# This .cnf file starts 4 servers without enabling Galera. +# The galera_migrate.test will set wsrep_provider and the other settings as needed. +# + +!include include/default_mysqld.cnf + +[mysqld] +binlog-format=row +innodb_autoinc_lock_mode=2 +innodb_flush_log_at_trx_commit=2 +log-bin=mysqld-bin + +wsrep_node_address=127.0.0.1 +wsrep_causal_reads=ON +wsrep_sync_wait = 7 + +[mysqld.1] +#galera_port=@OPT.port +#ist_port=@OPT.port +#sst_port=@OPT.port + +[mysqld.2] +#galera_port=@OPT.port +#ist_port=@OPT.port +#sst_port=@OPT.port + +[mysqld.3] +#galera_port=@OPT.port +#ist_port=@OPT.port +#sst_port=@OPT.port + +[mysqld.4] +#galera_port=@OPT.port +#ist_port=@OPT.port +#sst_port=@OPT.port + +[ENV] +NODE_MYPORT_1= @mysqld.1.port +NODE_MYSOCK_1= @mysqld.1.socket + +NODE_MYPORT_2= @mysqld.2.port +NODE_MYSOCK_2= @mysqld.2.socket + +NODE_MYPORT_3= @mysqld.3.port +NODE_MYSOCK_3= @mysqld.3.socket + +NODE_MYPORT_4= @mysqld.4.port +NODE_MYSOCK_4= @mysqld.4.socket + +NODE_GALERAPORT_1= @mysqld.1.#galera_port +NODE_GALERAPORT_2= @mysqld.2.#galera_port +NODE_GALERAPORT_3= @mysqld.3.#galera_port +NODE_GALERAPORT_4= @mysqld.4.#galera_port + +NODE_SSTPORT_1= @mysqld.1.#sst_port +NODE_SSTPORT_2= @mysqld.2.#sst_port +NODE_SSTPORT_3= @mysqld.3.#sst_port +NODE_SSTPORT_4= @mysqld.4.#sst_port diff --git a/mysql-test/suite/galera/t/galera_migrate.test b/mysql-test/suite/galera/t/galera_migrate.test new file mode 100644 index 00000000000..873640b88d4 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_migrate.test @@ -0,0 +1,204 @@ +# +# Execute a migration from MariaDB replication to Galera replication. +# The test starts with 4 stand-alone servers defined by galera_migrate.cnf and then +# performs the following steps: +# +# 1. Begin with a single MySQL server +# 2. Establish traditional MySQL master-slave replication +# 3. Attach a new sever to serve as a MySQL replication slave +# 4. Enable Galera on the new slave and create a single-node Galera cluster +# 5. Attach a second Galera node +# 6. Turn off the traditional replication parts of the system +# 7. Continue replicating within Galera only +# + +--source include/big_test.inc +--source include/have_innodb.inc +--source include/have_log_bin.inc + +# +# Step #1 Begin with a single server +# + +--connect node_1, 127.0.0.1, root, , test, $NODE_MYPORT_1 + +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); + +# +# Step #2. Establish traditional MySQL replication +# + +--connect node_2, 127.0.0.1, root, , test, $NODE_MYPORT_2 +--disable_query_log +--eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT = $NODE_MYPORT_1; +--enable_query_log +START SLAVE; + +--connection node_1 +INSERT INTO t1 VALUES (2); + +--connection 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(*) = 2 FROM t1; +--source include/wait_condition.inc + +# +# Step #3. Attach a second slave, later to be converted to Galera +# + +--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3 +--disable_query_log +--eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT = $NODE_MYPORT_1; +--enable_query_log +START SLAVE USER='root'; + +--connection node_1 +INSERT INTO t1 VALUES (3); + +--connection node_3 +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; +--source include/wait_condition.inc + +--let $wait_condition = SELECT COUNT(*) = 3 FROM t1; +--source include/wait_condition.inc + +# +# Step #4. Convert this MySQL slave into a Galera node +# + +--connection node_1 +INSERT INTO t1 VALUES (4); + +--connection node_3 +--disable_query_log +--eval SET GLOBAL wsrep_provider='$WSREP_PROVIDER' +--eval SET GLOBAL wsrep_provider_options='base_port=$NODE_GALERAPORT_3' +--enable_query_log +SET GLOBAL wsrep_cluster_address='gcomm://'; + +--connection node_1 +INSERT INTO t1 VALUES (5); + +--connection node_3 +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; +--source include/wait_condition.inc +--let $wait_condition = SELECT COUNT(*) = 5 FROM t1; +--source include/wait_condition.inc + +--let $wait_condition = SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready'; +--source include/wait_condition.inc + +SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; +SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; + +--connection node_1 +INSERT INTO t1 VALUES (6); + +# +# Step #5. Attach a second Galera node using mysqldump SST +# + +--connection node_3 +# We need a user with a password for mysqldump SST +GRANT ALL PRIVILEGES ON *.* TO 'sst' IDENTIFIED BY 'sst'; +SET GLOBAL wsrep_sst_auth = 'sst:sst'; + +--connect node_4, 127.0.0.1, root, , test, $NODE_MYPORT_4 +GRANT ALL PRIVILEGES ON *.* TO 'sst' IDENTIFIED BY 'sst'; + +--disable_query_log +--eval SET GLOBAL wsrep_sst_method = 'mysqldump'; +--eval SET GLOBAL wsrep_provider='$WSREP_PROVIDER' +--eval SET GLOBAL wsrep_provider_options='base_port=$NODE_GALERAPORT_4' +--eval SET GLOBAL wsrep_sst_receive_address = '127.0.0.2:$NODE_MYPORT_4'; +--eval SET GLOBAL wsrep_cluster_address='gcomm://127.0.0.1:$NODE_GALERAPORT_3' +--enable_query_log + +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; +--source include/wait_condition.inc + +--let $wait_condition = SELECT COUNT(*) = 6 FROM t1; +--source include/wait_condition.inc + +--let $wait_condition = SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready'; +--source include/wait_condition.inc + +SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; +SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; + + +# +# Step #6. Turn off traditional replication +# + +--connection node_2 +STOP SLAVE; +RESET SLAVE ALL; + +--connection node_3 +STOP SLAVE; +RESET SLAVE ALL; + +# +# Step #7. Continue replicating within Galera only +# + +# We need fresh connections due to galera#191 + +--connect node_3a, 127.0.0.1, root, , test, $NODE_MYPORT_3 +INSERT INTO t1 VALUES (7); + +--connect node_4a, 127.0.0.1, root, , test, $NODE_MYPORT_4 +INSERT INTO t1 VALUES (8); + +--connection node_4a +SELECT COUNT(*) = 8 FROM t1; + +--let $wait_condition = SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready'; +--source include/wait_condition.inc + +SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; +SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; + +--connection node_3a +SELECT COUNT(*) = 8 FROM t1; + +--let $wait_condition = SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready'; +--source include/wait_condition.inc + +SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; +SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; + +# +# Teardown +# + +--connection node_1 +DROP TABLE t1; + +--connection node_2 +DROP TABLE t1; + +--connection node_3 +SET GLOBAL wsrep_provider = 'none'; +SET GLOBAL wsrep_sst_auth = ''; +SET GLOBAL wsrep_provider_options = ''; +DROP TABLE t1; +DROP USER sst; + +--connection node_4 +SET GLOBAL wsrep_provider = 'none'; +SET GLOBAL wsrep_sst_method = 'rsync'; +SET GLOBAL wsrep_provider_options = ''; +SET GLOBAL wsrep_sst_receive_address = 'AUTO'; +DROP TABLE t1; +DROP USER sst; + +CALL mtr.add_suppression("InnoDB: Error: Table \"mysql\"\\.\"innodb_index_stats\" not found"); diff --git a/mysql-test/suite/galera/t/galera_multi_database.test b/mysql-test/suite/galera/t/galera_multi_database.test new file mode 100644 index 00000000000..6e06aaaa2c6 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_multi_database.test @@ -0,0 +1,43 @@ +# +# Test that identical updates can be delivered to two separate +# databases without this causing a certification conflict +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +CREATE DATABASE d1; +CREATE TABLE d1.t1(f1 INTEGER) ENGINE=InnoDB; + +CREATE DATABASE d2; +CREATE TABLE d2.t1(f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; + +--connection node_1 +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO d1.t1 VALUES (1); + +--connection node_2 +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO d2.t1 VALUES (1); + +--connection node_1 +COMMIT; + +--connection node_2 +COMMIT; + +SELECT COUNT(*) = 1 FROM d1.t1; +SELECT COUNT(*) = 1 FROM d2.t1; + +--connection node_1 + +SELECT COUNT(*) = 1 FROM d1.t1; +SELECT COUNT(*) = 1 FROM d2.t1; + +DROP TABLE d1.t1; +DROP TABLE d2.t1; + +DROP DATABASE d1; +DROP DATABASE d2; diff --git a/mysql-test/suite/galera/t/galera_myisam_autocommit.test b/mysql-test/suite/galera/t/galera_myisam_autocommit.test new file mode 100644 index 00000000000..b01b5dc07f7 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_myisam_autocommit.test @@ -0,0 +1,45 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc + +# +# This tests simple autocommit replication of MyISAM tables. No updates arrive on the slave. +# + +# Without a PK + +CREATE TABLE t1 (f1 INTEGER) ENGINE=MyISAM; + +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2), (3); +INSERT INTO t1 SELECT 4 FROM DUAL UNION ALL SELECT 5 FROM DUAL; + +CREATE TABLE t2 (f1 INTEGER PRIMARY KEY) ENGINE=MyISAM; +INSERT INTO t2 VALUES (1); +INSERT INTO t2 VALUES (2), (3); +INSERT INTO t2 SELECT 4 FROM DUAL UNION ALL SELECT 5 FROM DUAL; + +# Error +--error ER_DUP_ENTRY +INSERT INTO t2 VALUES (6), (1); + +# UPDATE + +UPDATE t1 SET f1 = 9; +UPDATE t2 SET f1 = 9 WHERE f1 = 1; + +# DELETE + +DELETE FROM t1 WHERE f1 = 9; +DELETE FROM t2 WHERE f1 = 9; + +# TRUNCATE + +TRUNCATE TABLE t1; +TRUNCATE TABLE t1; + +--connection node_2 +SELECT COUNT(*) = 0 FROM t1; +SELECT COUNT(*) = 0 FROM t2; + +DROP TABLE t1; +DROP TABLE t2; diff --git a/mysql-test/suite/galera/t/galera_myisam_transactions.test b/mysql-test/suite/galera/t/galera_myisam_transactions.test new file mode 100644 index 00000000000..00e0bf3fdca --- /dev/null +++ b/mysql-test/suite/galera/t/galera_myisam_transactions.test @@ -0,0 +1,36 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc + +# +# This tests MyISAM tables in transactions. No MyISAM updates arrive on the slave, but InnoDB ones do. +# + +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +CREATE TABLE t2 (f1 INTEGER) ENGINE=MyISAM; +CREATE TABLE t3 (f1 INTEGER) ENGINE=MyISAM; + +CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW INSERT INTO t3 VALUES (NEW.f1); + +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1); +COMMIT; + +--connection node_2 +SELECT COUNT(*) = 1 FROM t1; +SELECT COUNT(*) = 0 FROM t2; +SELECT COUNT(*) = 0 FROM t2; + +--connection node_1 +START TRANSACTION; +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1); +ROLLBACK; + +--connection node_2 +SELECT COUNT(*) = 1 FROM t1; +SELECT COUNT(*) = 0 FROM t2; +SELECT COUNT(*) = 0 FROM t2; + +DROP TABLE t1, t2, t3; diff --git a/mysql-test/suite/galera/t/galera_nopk_unicode.test b/mysql-test/suite/galera/t/galera_nopk_unicode.test new file mode 100644 index 00000000000..e036e14ebe0 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_nopk_unicode.test @@ -0,0 +1,43 @@ +# +# Test non-ascii data in table without a PK +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +CREATE TABLE t1 ( + f1 VARCHAR(255), + KEY (f1) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +INSERT INTO t1 VALUES ('текст'); + +--connection node_2 +SELECT f1 = 'текст' FROM t1; + +# +# Provoke a conflict +# + +--connection node_1 +SET AUTOCOMMIT=OFF; +START TRANSACTION; +UPDATE t1 SET f1 = 'текст2'; + +--connection node_2 +SET AUTOCOMMIT=OFF; +START TRANSACTION; +UPDATE t1 SET f1 = 'текст3'; + +--connection node_1 +COMMIT; + +--connection node_2 +--error ER_LOCK_DEADLOCK +COMMIT; + +SELECT f1 = 'текст2' FROM t1; +SELECT f1 = 'текст2' FROM t1 WHERE f1 = 'текст2'; + + +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_parallel_apply_lock_table.test b/mysql-test/suite/galera/t/galera_parallel_apply_lock_table.test new file mode 100644 index 00000000000..a071a1fab1b --- /dev/null +++ b/mysql-test/suite/galera/t/galera_parallel_apply_lock_table.test @@ -0,0 +1,51 @@ +# +# Test that a LOCK TABLE on the slave will cause all applier threads to block, +# Even though the two INSERTS are independent transactions, the fact that t1 is locked +# prevents the applier thread from committing the insert against t2, as commits are done +# in order. +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB; +CREATE TABLE t2 (id INT PRIMARY KEY) ENGINE=InnoDB; + +--connection node_2 + +--let $wsrep_slave_threads_orig = `SELECT @@wsrep_slave_threads` +--let $wsrep_sync_wait_orig = `SELECT @@wsrep_sync_wait` + +SET GLOBAL wsrep_slave_threads = 2; +LOCK TABLE t1 READ; + +--connection node_1 +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1); + +# We use a separate connection here so that we can SELECT from both tables +# without running into "table t2 was not locked" error. + +--let $galera_connection_name = node_2a +--let $galera_server_number = 2 +--source include/galera_connect.inc +--connection node_2a +--sleep 1 +SET SESSION wsrep_sync_wait=0; +SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE LIKE '%applied write set%'; +SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE LIKE '%Waiting for table level lock%'; +SELECT COUNT(*) = 0 FROM t1; +SELECT COUNT(*) = 0 FROM t2; + +--connection node_2 +UNLOCK TABLES; + +--connection node_2a +--eval SET SESSION wsrep_sync_wait = $wsrep_sync_wait_orig; +SELECT COUNT(*) = 1 FROM t1; +SELECT COUNT(*) = 1 FROM t2; +SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE LIKE 'closing tables'; + +--eval SET GLOBAL wsrep_slave_threads = $wsrep_slave_threads_orig; +DROP TABLE t1; +DROP TABLE t2; diff --git a/mysql-test/suite/galera/t/galera_parallel_autoinc_largetrx.test b/mysql-test/suite/galera/t/galera_parallel_autoinc_largetrx.test new file mode 100644 index 00000000000..a192044754d --- /dev/null +++ b/mysql-test/suite/galera/t/galera_parallel_autoinc_largetrx.test @@ -0,0 +1,50 @@ +## +## This test tests parallel application of multiple auto-increment insert transactions +## + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +# Create a second connection to node1 so that we can run transactions concurrently +--let $galera_connection_name = node_1a +--let $galera_server_number = 1 +--source include/galera_connect.inc + +--connection node_1 +CREATE TABLE ten (f1 INTEGER); +INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); + +CREATE TABLE t1 (f1 INTEGER AUTO_INCREMENT PRIMARY KEY, f2 INTEGER) Engine=InnoDB; +--connection node_2 +--let $wsrep_slave_threads_orig = `SELECT @@wsrep_slave_threads` +SET GLOBAL wsrep_slave_threads = 4; + +--connection node_1 +--send INSERT INTO t1 (f2) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4; + +--connection node_1a +--send INSERT INTO t1 (f2) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4; + +--connection node_2 +--send INSERT INTO t1 (f2) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4; + +--connection node_1 +--reap + +--connection node_1a +--reap + +--connection node_2 +--reap +SELECT COUNT(*) = 30000 FROM t1; +SELECT COUNT(DISTINCT f1) = 30000 FROM t1; +SELECT COUNT(*) = 5 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user'; + +--disable_query_log +--eval SET GLOBAL wsrep_slave_threads = $wsrep_slave_threads_orig; +--enable_query_log + +--connection default +DROP TABLE t1; +DROP TABLE ten; + diff --git a/mysql-test/suite/galera/t/galera_parallel_autoinc_manytrx.test b/mysql-test/suite/galera/t/galera_parallel_autoinc_manytrx.test new file mode 100644 index 00000000000..d67eba4d37c --- /dev/null +++ b/mysql-test/suite/galera/t/galera_parallel_autoinc_manytrx.test @@ -0,0 +1,53 @@ +## +## Tests the parallel application of many small-ish auto-increment insert transactions +## + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +# Create a second connection to node1 so that we can run transactions concurrently +--let $galera_connection_name = node_1a +--let $galera_server_number = 1 +--source include/galera_connect.inc + +--connection node_1 +CREATE TABLE ten (f1 INTEGER); +INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); + +CREATE TABLE t1 (f1 INTEGER AUTO_INCREMENT PRIMARY KEY, f2 INTEGER) Engine=InnoDB; +--connection node_2 +--let $wsrep_slave_threads_orig = `SELECT @@wsrep_slave_threads` +SET GLOBAL wsrep_slave_threads = 4; + +--connection node_1 +--let $count = 1000 +while ($count) +{ + --disable_query_log + INSERT INTO t1 (f2) SELECT 1 FROM ten AS a1; + --enable_query_log + --dec $count +} + +--connection node_2 +--let $count = 1000 +while ($count) +{ + --disable_query_log + INSERT INTO t1 (f2) SELECT 1 FROM ten AS a1; + --enable_query_log + --dec $count +} + +SELECT COUNT(*) = 20000 FROM t1; +SELECT COUNT(DISTINCT f1) = 20000 FROM t1; +SELECT COUNT(*) = 4 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE LIKE 'closing tables'; + +--disable_query_log +--eval SET GLOBAL wsrep_slave_threads = $wsrep_slave_threads_orig; +--enable_query_log + +--connection default +DROP TABLE t1; +DROP TABLE ten; + diff --git a/mysql-test/suite/galera/t/galera_parallel_simple.test b/mysql-test/suite/galera/t/galera_parallel_simple.test new file mode 100644 index 00000000000..a1429954980 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_parallel_simple.test @@ -0,0 +1,45 @@ +# +# Test that SHOW PROCESSLIST reports that two slave threads have been involved in applying +# two independent transactions +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +--let $wsrep_slave_threads_orig = `SELECT @@wsrep_slave_threads` + +CREATE TABLE t1 (id INT) ENGINE=InnoDB; +CREATE TABLE t2 (id INT) ENGINE=InnoDB; + +--connection node_2 +SET GLOBAL wsrep_slave_threads = 2; + +--connection node_1 +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1); + +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1); + +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1); + +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1); + +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1); + +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1); + +--connection node_2 + +SELECT COUNT(*) = 6 FROM t1; +SELECT COUNT(*) = 6 FROM t2; +SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE LIKE 'closing tables'; + +--eval SET GLOBAL wsrep_slave_threads = $wsrep_slave_threads_orig; + +DROP TABLE t1; +DROP TABLE t2; diff --git a/mysql-test/suite/galera/t/galera_pc_ignore_sb.test b/mysql-test/suite/galera/t/galera_pc_ignore_sb.test new file mode 100644 index 00000000000..f63215ebe4a --- /dev/null +++ b/mysql-test/suite/galera/t/galera_pc_ignore_sb.test @@ -0,0 +1,49 @@ +# +# Test pc.ignore_sb=true wsrep_provider option . Killing one node should leave the other running. +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +# Save original auto_increment_offset values. +--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`; + +--connection node_1 +--let $wsrep_cluster_address_orig = `SELECT @@wsrep_cluster_address` +--let $wsrep_provider_options_orig = `SELECT @@wsrep_provider_options` + +SET GLOBAL wsrep_provider_options = 'pc.ignore_sb=true'; + +--connection node_2 +--source include/kill_galera.inc + +--connection node_1 +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +DROP TABLE t1; + +SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready'; + +# Reset the master and restart the slave so that post-test checks can run + +SET GLOBAL wsrep_cluster_address = ''; +--disable_query_log +--eval SET GLOBAL wsrep_cluster_address = '$wsrep_cluster_address_orig'; +--eval SET GLOBAL wsrep_provider_options = '$wsrep_provider_options_orig'; +--enable_query_log + +--connection node_2 +--source include/start_mysqld.inc +--source include/wait_until_connected_again.inc + +--disable_query_log +# Restore original auto_increment_offset values. +--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; +--enable_query_log diff --git a/mysql-test/suite/galera/t/galera_pk_bigint_signed.test b/mysql-test/suite/galera/t/galera_pk_bigint_signed.test new file mode 100644 index 00000000000..12a8a8f5d64 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_pk_bigint_signed.test @@ -0,0 +1,46 @@ +# +# PK that is a BIGINT SIGNED +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +CREATE TABLE t1 (f1 BIGINT SIGNED PRIMARY KEY, f2 VARCHAR(5)) ENGINE=InnoDB; + +INSERT INTO t1 VALUES + (-9223372036854775808, 'min'), + (9223372036854775807, 'max') +; + +--connection node_2 +SELECT * FROM t1; + +UPDATE t1 SET f2 = CONCAT(f2, '_'); + +--connection node_1 +SELECT * FROM t1; + +# +# Deadlock +# + +--connection node_1 +SET AUTOCOMMIT=OFF; +START TRANSACTION; +UPDATE t1 SET f2 = 'foo' WHERE f1 = -9223372036854775808; + +--connection node_2 +SET AUTOCOMMIT=OFF; +START TRANSACTION; +UPDATE t1 SET f2 = 'bar' WHERE f1 = -9223372036854775808; + +--connection node_1 +COMMIT; +SET AUTOCOMMIT=ON; + +--connection node_2 +--error ER_LOCK_DEADLOCK +COMMIT; +SET AUTOCOMMIT=ON; + +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_pk_bigint_unsigned.test b/mysql-test/suite/galera/t/galera_pk_bigint_unsigned.test new file mode 100644 index 00000000000..2bb02d5ea4e --- /dev/null +++ b/mysql-test/suite/galera/t/galera_pk_bigint_unsigned.test @@ -0,0 +1,45 @@ +# +# PK that is a BIGINT UNSIGNED +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +CREATE TABLE t1 (f1 BIGINT UNSIGNED PRIMARY KEY, f2 VARCHAR(5)) ENGINE=InnoDB; + +INSERT INTO t1 VALUES + (18446744073709551615, 'max') +; + +--connection node_2 +SELECT f1 = 18446744073709551615 FROM t1; + +UPDATE t1 SET f2 = CONCAT(f2, '_'); + +--connection node_1 +SELECT f1 = 18446744073709551615 FROM t1; + +# +# Deadlock +# + +--connection node_1 +SET AUTOCOMMIT=OFF; +START TRANSACTION; +UPDATE t1 SET f2 = 'foo' WHERE f1 = 18446744073709551615; + +--connection node_2 +SET AUTOCOMMIT=OFF; +START TRANSACTION; +UPDATE t1 SET f2 = 'bar' WHERE f1 = 18446744073709551615; + +--connection node_1 +COMMIT; +SET AUTOCOMMIT=ON; + +--connection node_2 +--error ER_LOCK_DEADLOCK +COMMIT; +SET AUTOCOMMIT=ON; + +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_query_cache-master.opt b/mysql-test/suite/galera/t/galera_query_cache-master.opt new file mode 100644 index 00000000000..cb983993b91 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_query_cache-master.opt @@ -0,0 +1,3 @@ +--query_cache_type=1 --query_cache_size=1355776 + + diff --git a/mysql-test/suite/galera/t/galera_query_cache.test b/mysql-test/suite/galera/t/galera_query_cache.test new file mode 100644 index 00000000000..900faba0e1b --- /dev/null +++ b/mysql-test/suite/galera/t/galera_query_cache.test @@ -0,0 +1,67 @@ +--source include/have_query_cache.inc +--source include/galera_cluster.inc +--source include/have_innodb.inc + +# +# Ensure that the query cache behaves properly with respect to Galera +# +# * in the absence of updates, the query cache does serve cached results +# * any cache-invalidating query on the remote node also causes the local cache to be invalidated +# + +CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB; + +INSERT INTO t1 VALUES (1); + +--connection node_2 +RESET QUERY CACHE; +FLUSH STATUS; + +# +# 1. Cache works +# + +SELECT COUNT(*) FROM t1; +SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Qcache_queries_in_cache'; + +SELECT COUNT(*) FROM t1; +SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'Qcache_hits'; + +# +# 2. Cache is invalidated by DML on remote node +# + +--connection node_1 +INSERT INTO t1 VALUES (2); + +--connection node_2 +FLUSH STATUS; + +SELECT VARIABLE_VALUE = 0 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Qcache_queries_in_cache'; +SELECT COUNT(*) FROM t1; +SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Qcache_queries_in_cache'; + +SELECT VARIABLE_VALUE = 0 FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'Qcache_hits'; +SELECT COUNT(*) FROM t1; +SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'Qcache_hits'; + +# +# 3. Cache is invalidated by DDL on remote node +# + +--connection node_1 +ALTER TABLE t1 ADD COLUMN f2 INTEGER; + +--connection node_2 +FLUSH STATUS; + +SELECT VARIABLE_VALUE = 0 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Qcache_queries_in_cache'; +SELECT COUNT(*) FROM t1; +SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Qcache_queries_in_cache'; + +SELECT VARIABLE_VALUE = 0 FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'Qcache_hits'; +SELECT COUNT(*) FROM t1; +SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'Qcache_hits'; + +DROP TABLE t1; + diff --git a/mysql-test/suite/galera/t/galera_read_only.test b/mysql-test/suite/galera/t/galera_read_only.test new file mode 100644 index 00000000000..828f35d2ba3 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_read_only.test @@ -0,0 +1,23 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc + +# +# Ensure that the read_only option does not apply to Galera appliers and that replication +# continues, the way MySQL replication would. +# + +CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB; + +--connection node_2 +SET GLOBAL read_only=TRUE; + +--connection node_1 +INSERT INTO t1 VALUES (1); + +--connection node_2 +SELECT COUNT(*) = 1 FROM t1; + +SET GLOBAL read_only=FALSE; + +DROP TABLE t1; + diff --git a/mysql-test/suite/galera/t/galera_repl_key_format_flat16.test b/mysql-test/suite/galera/t/galera_repl_key_format_flat16.test new file mode 100644 index 00000000000..8749c20faed --- /dev/null +++ b/mysql-test/suite/galera/t/galera_repl_key_format_flat16.test @@ -0,0 +1,34 @@ +# +# Test repl.key_format = FLAT16 . Since it is very difficult to cause a collision on a 16-byte hash, +# we simply verify that the option is settable and that replication works. +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +--connection node_1 +--let $wsrep_provider_options_orig = `SELECT @@wsrep_provider_options` +SET GLOBAL wsrep_provider_options = 'repl.key_format=FLAT16'; + +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (123); + +CREATE TABLE t2 (f1 VARCHAR(256)) ENGINE=InnoDB; +INSERT INTO t2 VALUES (REPEAT('a', 256)); + +--connection node_2 +SELECT COUNT(*) = 1 FROM t1; +UPDATE t1 SET f1 = 234; +UPDATE t2 SET f1 = REPEAT('b', 256); + +--connection node_1 +SELECT COUNT(*) = 1 FROM t1 WHERE f1 = 234; +SELECT COUNT(*) = 1 FROM t2 WHERE f1 = REPEAT('b', 256); + + +--disable_query_log +--eval SET GLOBAL wsrep_provider_options = '$wsrep_provider_options_orig'; +--enable_query_log + +DROP TABLE t1; +DROP TABLE t2; diff --git a/mysql-test/suite/galera/t/galera_repl_max_ws_size.test b/mysql-test/suite/galera/t/galera_repl_max_ws_size.test new file mode 100644 index 00000000000..37a2f7d4ce3 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_repl_max_ws_size.test @@ -0,0 +1,25 @@ +# +# Test repl.max_ws_size . A transaction larger than this size can not commit. +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +--connection node_1 +--let $wsrep_provider_options_orig = `SELECT @@wsrep_provider_options` + +CREATE TABLE t1 (f1 VARCHAR(512)) ENGINE=InnoDB; + +SET GLOBAL wsrep_provider_options = 'repl.max_ws_size=512'; + +--error ER_ERROR_DURING_COMMIT +INSERT INTO t1 VALUES (REPEAT('a', 512)); + +SELECT COUNT(*) = 0 FROM t1; + +--disable_query_log +--eval SET GLOBAL wsrep_provider_options = '$wsrep_provider_options_orig'; +--enable_query_log + +DROP TABLE t1; + diff --git a/mysql-test/suite/galera/t/galera_restart_nochanges.test b/mysql-test/suite/galera/t/galera_restart_nochanges.test new file mode 100644 index 00000000000..8eb7617b8a6 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_restart_nochanges.test @@ -0,0 +1,23 @@ +# +# This test restarts a slave while no updates have been performed on the master. No SST is performed. +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +--connection node_1 +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); + +--connection node_2 +--source include/restart_mysqld.inc + +--let $galera_connection_name = node_2a +--let $galera_server_number = 2 +--source include/galera_connect.inc +--connection node_2a + +SELECT COUNT(*) = 1 FROM t1; +SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; + +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_rsu_add_pk.test b/mysql-test/suite/galera/t/galera_rsu_add_pk.test new file mode 100644 index 00000000000..7db990d7be1 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_rsu_add_pk.test @@ -0,0 +1,43 @@ +# +# ALTER TABLE ... ADD PRIMARY KEY under Rolling Schema Upgrade +# + +--source include/big_test.inc +--source include/galera_cluster.inc +--source include/have_innodb.inc + +--connection node_1 +CREATE TABLE ten (f1 INTEGER); +INSERT INTO ten VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); + +CREATE TABLE t1 (f1 INTEGER) Engine=InnoDB; + +# Insert some values before the ALTER +INSERT INTO t1 (f1) SELECT 000000 + (10000 * a1.f1) + (1000 * a2.f1) + (100 * a3.f1) + (10 * a4.f1) + a5.f1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5; + +# Insert more values while the ALTER is running +--send INSERT INTO t1 (f1) SELECT 100000 + (10000 * a1.f1) + (1000 * a2.f1) + (100 * a3.f1) + (10 * a4.f1) + a5.f1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5; + +--connection node_2 +SET SESSION wsrep_OSU_method = "RSU"; +ALTER TABLE t1 ADD PRIMARY KEY (f1); +SET SESSION wsrep_OSU_method = "TOI"; + +# Insert values after the ALTER +INSERT INTO t1 (f1) SELECT 200000 + (10000 * a1.f1) + (1000 * a2.f1) + (100 * a3.f1) + (10 * a4.f1) + a5.f1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5; + + +SELECT COUNT(*) = 300000 FROM t1; +SELECT MAX(f1) = 299999 FROM t1; + +--connection node_1 +--reap +SELECT COUNT(*) = 300000 FROM t1; +SELECT MAX(f1) = 299999 FROM t1; + +SET SESSION wsrep_OSU_method = "RSU"; +ALTER TABLE t1 ADD PRIMARY KEY (f1); +SET SESSION wsrep_OSU_method = "TOI"; + +DROP TABLE t1; +DROP TABLE ten; diff --git a/mysql-test/suite/galera/t/galera_rsu_drop_pk.test b/mysql-test/suite/galera/t/galera_rsu_drop_pk.test new file mode 100644 index 00000000000..e64259494d1 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_rsu_drop_pk.test @@ -0,0 +1,58 @@ +# +# ALTER TABLE ... DROP PRIMARY KEY under Rolling Schema Upgrade +# + +--source include/big_test.inc +--source include/galera_cluster.inc +--source include/have_innodb.inc + +--connection node_1 +CREATE TABLE ten (f1 INTEGER); +INSERT INTO ten VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); + +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) Engine=InnoDB; + +# Insert some values before the ALTER +INSERT INTO t1 (f1) SELECT 000000 + (10000 * a1.f1) + (1000 * a2.f1) + (100 * a3.f1) + (10 * a4.f1) + a5.f1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5; + +# Insert more values while the ALTER is running +--send INSERT INTO t1 (f1) SELECT 100000 + (10000 * a1.f1) + (1000 * a2.f1) + (100 * a3.f1) + (10 * a4.f1) + a5.f1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5; + +--connection node_2 +SET SESSION wsrep_OSU_method = "RSU"; +ALTER TABLE t1 DROP PRIMARY KEY; +SET SESSION wsrep_OSU_method = "TOI"; + +# Insert even more data after the ALTER has completed +INSERT INTO t1 (f1) SELECT 200000 + (10000 * a1.f1) + (1000 * a2.f1) + (100 * a3.f1) + (10 * a4.f1) + a5.f1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5; + +SELECT COUNT(*) = 300000 FROM t1; +SELECT MAX(f1) = 299999 FROM t1; + +--connection node_1 +--reap +SELECT COUNT(*) = 300000 FROM t1; +SELECT MAX(f1) = 299999 FROM t1; + +SET SESSION wsrep_OSU_method = "RSU"; +ALTER TABLE t1 DROP PRIMARY KEY; +SET SESSION wsrep_OSU_method = "TOI"; + +# Insert some previously-conflicting values after the ALTER has been applied on all nodes. +--connection node_2 +INSERT INTO t1 (f1) VALUES (1); +INSERT INTO t1 (f1) VALUES (10); + +--connection node_1 +SELECT COUNT(*) = 2 FROM t1 WHERE f1 = 1; +SELECT COUNT(*) = 2 FROM t1 WHERE f1 = 10; + +INSERT INTO t1 (f1) VALUES (100); +INSERT INTO t1 (f1) VALUES (1000); + +--connection node_2 +SELECT COUNT(*) = 2 FROM t1 WHERE f1 = 100; +SELECT COUNT(*) = 2 FROM t1 WHERE f1 = 1000; + +DROP TABLE t1; +DROP TABLE ten; diff --git a/mysql-test/suite/galera/t/galera_rsu_error.test b/mysql-test/suite/galera/t/galera_rsu_error.test new file mode 100644 index 00000000000..cad8154ac76 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_rsu_error.test @@ -0,0 +1,31 @@ +# +# Test DDL errors under Rolling Schema Upgrade +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +CREATE TABLE t1 (f1 INTEGER) Engine=InnoDB; +INSERT INTO t1 VALUES (1), (1); + +--connection node_2 +SET SESSION wsrep_OSU_method = "RSU"; +--error ER_DUP_ENTRY +ALTER TABLE t1 ADD PRIMARY KEY (f1); +SET SESSION wsrep_OSU_method = "TOI"; + +# The ALTER has no effect +SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE TABLE_NAME = 't1'; + +INSERT INTO t1 VALUES (1); + +--connection node_1 +SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE TABLE_NAME = 't1'; +SELECT COUNT(*) = 3 FROM t1; + +INSERT INTO t1 VALUES (1); + +--connection node_2 +SELECT COUNT(3) = 4 FROM t1; + +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_rsu_simple.test b/mysql-test/suite/galera/t/galera_rsu_simple.test new file mode 100644 index 00000000000..5841dbd8006 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_rsu_simple.test @@ -0,0 +1,34 @@ +# +# Test Rolling Schema Upgrade +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) Engine=InnoDB; + +--connection node_2 +SET SESSION wsrep_OSU_method = "RSU"; +ALTER TABLE t1 ADD COLUMN f2 INTEGER; +SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; + +--connection node_1 +# The ALTER above is not visible on node_1 +SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; + +INSERT INTO t1 VALUES (1); + +--connection node_2 +# The INSERT above is now visible on node_2 +SELECT COUNT(*) = 1 FROM t1; + +INSERT INTO t1 (f1) VALUES (2); + +--connection node_1 +# The ALTER has not replicated +SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; + +# However the INSERT above has +SELECT COUNT(*) = 2 FROM t1; + +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_sbr.test b/mysql-test/suite/galera/t/galera_sbr.test new file mode 100644 index 00000000000..33f45c6b532 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_sbr.test @@ -0,0 +1,27 @@ +# +# Test behavior if the user attempts to use statement-based replication +# +# SBR is not currently supported but we expect that no crashes or binlog-related assertions will be triggered. +# + +--source include/have_innodb.inc +--source include/galera_cluster.inc + +--connection node_1 +#SET GLOBAL binlog_format = 'STATEMENT'; +SET SESSION binlog_format = 'STATEMENT'; + +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); + +SET SESSION binlog_format = 'MIXED'; + +INSERT INTO t1 VALUES (2); + +--connection node_2 +SELECT COUNT(*) = 2 FROM t1; + +DROP TABLE t1; + +--connection node_1 +SET GLOBAL binlog_format = 'ROW'; diff --git a/mysql-test/suite/galera/t/galera_sbr_binlog-master.opt b/mysql-test/suite/galera/t/galera_sbr_binlog-master.opt new file mode 100644 index 00000000000..beae84b3862 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_sbr_binlog-master.opt @@ -0,0 +1 @@ +--log-bin diff --git a/mysql-test/suite/galera/t/galera_sbr_binlog.test b/mysql-test/suite/galera/t/galera_sbr_binlog.test new file mode 100644 index 00000000000..1291a4ff8a9 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_sbr_binlog.test @@ -0,0 +1,28 @@ +# +# Test behavior if the user attempts to use statement-based replication +# +# SBR is not currently supported but we expect that no crashes or binlog-related assertions will be triggered. +# + +--source include/have_log_bin.inc +--source include/have_innodb.inc +--source include/galera_cluster.inc + +--connection node_1 +#SET GLOBAL binlog_format = 'STATEMENT'; +SET SESSION binlog_format = 'STATEMENT'; + +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); + +SET SESSION binlog_format = 'MIXED'; + +INSERT INTO t1 VALUES (2); + +--connection node_2 +SELECT COUNT(*) = 2 FROM t1; + +DROP TABLE t1; + +--connection node_1 +SET GLOBAL binlog_format = 'ROW'; diff --git a/mysql-test/suite/galera/t/galera_split_brain.test b/mysql-test/suite/galera/t/galera_split_brain.test new file mode 100644 index 00000000000..c3e779618df --- /dev/null +++ b/mysql-test/suite/galera/t/galera_split_brain.test @@ -0,0 +1,53 @@ +# +# Confirm that with two nodes, killing one causes the other to stop accepting connections +# The pc.ignore_sb=true wsrep_provider option is tested in the galera_kill_* tests. +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +call mtr.add_suppression("WSREP: TO isolation failed for: "); + +--connection node_1 +--let $wsrep_cluster_address_orig = `SELECT @@wsrep_cluster_address` + +# Save original auto_increment_offset values. +--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`; + +--connection node_2 +--source include/kill_galera.inc + +--connection node_1 +--error ER_LOCK_DEADLOCK +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; + +# Reset the master and restart the slave so that post-test checks can run + +SET GLOBAL wsrep_cluster_address = ''; +--disable_query_log +--eval SET GLOBAL wsrep_cluster_address = '$wsrep_cluster_address_orig'; +--enable_query_log + +--source include/start_mysqld.inc +--sleep 5 +--source include/wait_until_connected_again.inc + +--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' +--source include/wait_condition.inc + +--sleep 5 + +--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2 +--source include/wait_until_connected_again.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_2a +--eval SET @@global.auto_increment_offset = $auto_increment_offset_node_2; +--enable_query_log + diff --git a/mysql-test/suite/galera/t/galera_sql_log_bin_zero.test b/mysql-test/suite/galera/t/galera_sql_log_bin_zero.test new file mode 100644 index 00000000000..b6965faa739 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_sql_log_bin_zero.test @@ -0,0 +1,25 @@ +# +# Test SET SESSION sql_log_bin = 0 . We expect that unlogged updates will not be replicated +# to the slave and that there will be no assertions in the process. +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; + +SET SESSION sql_log_bin = 0; + +INSERT INTO t1 VALUES (1); + +SET SESSION sql_log_bin = 1; + +INSERT INTO t1 VALUES (2); + + +--connection node_2 +SELECT COUNT(*) = 1 FROM t1; +SELECT COUNT(*) = 0 FROM t1 WHERE f1 = 1; + +--connection node_1 +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_ssl.cnf b/mysql-test/suite/galera/t/galera_ssl.cnf new file mode 100644 index 00000000000..1c22580cc15 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_ssl.cnf @@ -0,0 +1,7 @@ +!include ../galera_2nodes.cnf + +[mysqld.1] +wsrep_provider_options='base_port=@mysqld.1.#galera_port;gcache.size=10M;socket.ssl=yes;socket.ssl_cert=@ENV.MYSQL_TEST_DIR/std_data/galera-cert.pem;socket.ssl_key=@ENV.MYSQL_TEST_DIR/std_data/galera-key.pem' + +[mysqld.2] +wsrep_provider_options='base_port=@mysqld.2.#galera_port;gcache.size=10M;socket.ssl=yes;socket.ssl_cert=@ENV.MYSQL_TEST_DIR/std_data/galera-cert.pem;socket.ssl_key=@ENV.MYSQL_TEST_DIR/std_data/galera-key.pem' diff --git a/mysql-test/suite/galera/t/galera_ssl.test b/mysql-test/suite/galera/t/galera_ssl.test new file mode 100644 index 00000000000..8dc94dc1966 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_ssl.test @@ -0,0 +1,24 @@ +# +# Test node connections over SSL. The accompanying galera_ssl.cnf has a customized +# wsrep_provider_options setting that enables SSL. +# +# At this time, the actual operation of SSL is not visible only in the error log and not in SHOW STATUS. +# So this test can only check that the cluster has formed and is replicating. +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; +SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; + +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) Engine=InnoDB; +INSERT INTO t1 VALUES (1); + +--connection node_2 +SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; +SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; + +SELECT COUNT(*) = 1 FROM t1; + +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_sst_mysqldump.cnf b/mysql-test/suite/galera/t/galera_sst_mysqldump.cnf new file mode 100644 index 00000000000..574ae28b54a --- /dev/null +++ b/mysql-test/suite/galera/t/galera_sst_mysqldump.cnf @@ -0,0 +1,11 @@ +!include ../galera_2nodes.cnf + +# We do not set mysqldump-related SST options here because doing so on startup +# causes the first MTR connection to be forefully dropped by Galera, which in turn confuses MTR + +[mysqld.1] +wsrep_provider_options='base_port=@mysqld.1.#galera_port;gcache.size=1;pc.ignore_sb=true' + +[mysqld.2] +wsrep_provider_options='base_port=@mysqld.2.#galera_port;gcache.size=1;pc.ignore_sb=true' + diff --git a/mysql-test/suite/galera/t/galera_sst_mysqldump.test b/mysql-test/suite/galera/t/galera_sst_mysqldump.test new file mode 100644 index 00000000000..0b7171597dd --- /dev/null +++ b/mysql-test/suite/galera/t/galera_sst_mysqldump.test @@ -0,0 +1,18 @@ +--source include/big_test.inc +--source include/galera_cluster.inc +--source include/have_innodb.inc + +--source suite/galera/include/galera_sst_set_mysqldump.inc + +--source suite/galera/include/galera_st_disconnect_slave.inc + +# We set the required mysqldump SST options here so that they are used every time the server is restarted during the test +--let $start_mysqld_params = --wsrep_sst_auth=sst:sst --wsrep_sst_method=mysqldump --wsrep-sst-receive-address=127.0.0.1:$NODE_MYPORT_2 --skip-grant-tables + +--source suite/galera/include/galera_st_shutdown_slave.inc +--source suite/galera/include/galera_st_clean_slave.inc + +--source suite/galera/include/galera_st_kill_slave.inc +--source suite/galera/include/galera_st_kill_slave_ddl.inc + +--source suite/galera/include/galera_sst_restore.inc diff --git a/mysql-test/suite/galera/t/galera_sst_rsync.cnf b/mysql-test/suite/galera/t/galera_sst_rsync.cnf new file mode 100644 index 00000000000..93981d9daa7 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_sst_rsync.cnf @@ -0,0 +1,11 @@ +!include ../galera_2nodes.cnf + +[mysqld] +wsrep_sst_method=rsync + +[mysqld.1] +wsrep_provider_options='base_port=@mysqld.1.#galera_port;gcache.size=1;pc.ignore_sb=true' + +[mysqld.2] +wsrep_provider_options='base_port=@mysqld.2.#galera_port;gcache.size=1;pc.ignore_sb=true' + diff --git a/mysql-test/suite/galera/t/galera_sst_rsync.test b/mysql-test/suite/galera/t/galera_sst_rsync.test new file mode 100644 index 00000000000..c6823795e59 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_sst_rsync.test @@ -0,0 +1,9 @@ +--source include/big_test.inc +--source include/galera_cluster.inc +--source include/have_innodb.inc + +--source suite/galera/include/galera_st_shutdown_slave.inc +--source suite/galera/include/galera_st_clean_slave.inc + +--source suite/galera/include/galera_st_kill_slave.inc +--source suite/galera/include/galera_st_kill_slave_ddl.inc diff --git a/mysql-test/suite/galera/t/galera_sst_xtrabackup-v2.cnf b/mysql-test/suite/galera/t/galera_sst_xtrabackup-v2.cnf new file mode 100644 index 00000000000..47cb3e02292 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_sst_xtrabackup-v2.cnf @@ -0,0 +1,13 @@ +!include ../galera_2nodes.cnf + +[mysqld] +wsrep_sst_method=xtrabackup-v2 +wsrep_sst_auth="root:" +wsrep_debug=ON + +[mysqld.1] +wsrep_provider_options='base_port=@mysqld.1.#galera_port;gcache.size=1;pc.ignore_sb=true' + +[mysqld.2] +wsrep_provider_options='base_port=@mysqld.2.#galera_port;gcache.size=1;pc.ignore_sb=true' + diff --git a/mysql-test/suite/galera/t/galera_sst_xtrabackup-v2.test b/mysql-test/suite/galera/t/galera_sst_xtrabackup-v2.test new file mode 100644 index 00000000000..c6823795e59 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_sst_xtrabackup-v2.test @@ -0,0 +1,9 @@ +--source include/big_test.inc +--source include/galera_cluster.inc +--source include/have_innodb.inc + +--source suite/galera/include/galera_st_shutdown_slave.inc +--source suite/galera/include/galera_st_clean_slave.inc + +--source suite/galera/include/galera_st_kill_slave.inc +--source suite/galera/include/galera_st_kill_slave_ddl.inc diff --git a/mysql-test/suite/galera/t/galera_status_cluster.test b/mysql-test/suite/galera/t/galera_status_cluster.test new file mode 100644 index 00000000000..3299613d584 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_status_cluster.test @@ -0,0 +1,18 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc + +# +# A simple test for the wsrep_cluster_* status variables +# + +--connection node_1 + +SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; + +--connection node_2 + +SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; + + diff --git a/mysql-test/suite/galera/t/galera_status_local_state.test b/mysql-test/suite/galera/t/galera_status_local_state.test new file mode 100644 index 00000000000..09cdb25f80c --- /dev/null +++ b/mysql-test/suite/galera/t/galera_status_local_state.test @@ -0,0 +1,28 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc + +# +# Test wsrep_local_state . We can not reliably produce all possible statuses in MTR, but +# we can at least test for the ones we can. +# + +SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state'; +SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; + +SET GLOBAL wsrep_desync = 1; + +--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state'; +--source include/wait_condition.inc + +SELECT VARIABLE_VALUE = 'Donor/Desynced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; + +SET GLOBAL wsrep_desync = 0; + +--let $wait_condition = SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state'; +--source include/wait_condition.inc + +SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; + + + + diff --git a/mysql-test/suite/galera/t/galera_suspend_slave.test b/mysql-test/suite/galera/t/galera_suspend_slave.test new file mode 100644 index 00000000000..acee3626f7a --- /dev/null +++ b/mysql-test/suite/galera/t/galera_suspend_slave.test @@ -0,0 +1,51 @@ +## +## This test tests that transactions on the master will fail if the slave +## is made completely unresponsive by suspending the process. Resuming the +## process should allow replication to continue to run. +## + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +--connection node_1 +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; + +--connection node_2 +--let NODE_2_PIDFILE = `SELECT @@pid_file` +--disconnect node_2 + +--connection node_1 +--echo Suspending node_2 ... +--perl + my $pid_filename = $ENV{'NODE_2_PIDFILE'}; + my $mysqld_pid = `cat $pid_filename`; + chomp($mysqld_pid); + system("kill -19 $mysqld_pid"); + exit(0); +EOF + +--error ER_UNKNOWN_COM_ERROR,ER_LOCK_WAIT_TIMEOUT +INSERT INTO t1 VALUES (1); + +--echo Resuming node_2 ... +--perl + my $pid_filename = $ENV{'NODE_2_PIDFILE'}; + my $mysqld_pid = `cat $pid_filename`; + chomp($mysqld_pid); + system("kill -18 $mysqld_pid"); + exit(0); +EOF + +--sleep 10 +--source include/wait_until_ready.inc +INSERT INTO t1 VALUES (1); + +--let $galera_connection_name = node_2a +--let $galera_server_number = 2 +--source include/galera_connect.inc +--connection node_2a + +--source include/wait_until_ready.inc +SELECT COUNT(*) = 1 FROM t1; + +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_toi_alter_auto_increment.test b/mysql-test/suite/galera/t/galera_toi_alter_auto_increment.test new file mode 100644 index 00000000000..641d2101c80 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_toi_alter_auto_increment.test @@ -0,0 +1,120 @@ + +# +# Test the operation of ALTER TABLE ... AUTO_INCREMENT +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +--connection node_1 +CREATE TABLE ten (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); + +CREATE TABLE t1 (f1 INTEGER AUTO_INCREMENT PRIMARY KEY, f2 INTEGER) ENGINE=InnoDB; + +INSERT INTO t1 (f2) SELECT 1 FROM ten; + +--connection node_2 +INSERT INTO t1 (f2) SELECT 1 FROM ten; + +ALTER TABLE t1 AUTO_INCREMENT = 1000; +INSERT INTO t1 (f2) SELECT 1 FROM ten; + +--connection node_1 +INSERT INTO t1 (f2) SELECT 1 FROM ten; + +SELECT MIN(f1) >= 1000, COUNT(*) = 20, COUNT(DISTINCT f1) = 20 FROM t1 WHERE f1 >= 1000; + +--connection node_2 +SELECT MIN(f1) >= 1000, COUNT(*) = 20, COUNT(DISTINCT f1) = 20 FROM t1 WHERE f1 >= 1000; + +# +# AUTO_INCREMENT set to a value lower than the current one. +# The ALTER does nothing, the sequence continues from the current maximum. +# + +--connection node_1 +ALTER TABLE t1 AUTO_INCREMENT = 5; +INSERT INTO t1 (f2) SELECT 1 FROM ten; + +--connection node_2 +INSERT INTO t1 (f2) SELECT 1 FROM ten; +SELECT MIN(f1) >= 1000, COUNT(*) = 40, COUNT(DISTINCT f1) = 40 FROM t1 WHERE f1 >= 1000; + +--connection node_1 +SELECT MIN(f1) >= 1000, COUNT(*) = 40, COUNT(DISTINCT f1) = 40 FROM t1 WHERE f1 >= 1000; + +DROP TABLE t1; + +# +# Under wsrep_auto_increment_control = OFF +# + +--connection node_1 +--let $auto_increment_control_orig = `SELECT @@wsrep_auto_increment_control` +--let $auto_increment_increment_node1 = `SELECT @@auto_increment_increment` +--let $auto_increment_offset_node1 = `SELECT @@auto_increment_offset` + +# Restore stock MySQL defaults +SET GLOBAL wsrep_auto_increment_control = OFF; +SET GLOBAL auto_increment_increment = 1; +SET GLOBAL auto_increment_offset = 1; + +#Open a fresh connection to node_1 so that the variables above take effect +--let $galera_connection_name = node_1a +--let $galera_server_number = 1 +--source include/galera_connect.inc + +--connection node_2 +--let $auto_increment_increment_node2 = `SELECT @@auto_increment_increment` +--let $auto_increment_offset_node2 = `SELECT @@auto_increment_offset` + +SET GLOBAL wsrep_auto_increment_control = OFF; +SET GLOBAL auto_increment_increment = 1; +SET GLOBAL auto_increment_offset = 1; + +#Open a fresh connection to node_2 +--let $galera_connection_name = node_2a +--let $galera_server_number = 2 +--source include/galera_connect.inc + +--connection node_1a + +CREATE TABLE t1 (f1 INTEGER AUTO_INCREMENT PRIMARY KEY, f2 INTEGER) ENGINE=InnoDB; + +--connection node_2a + +ALTER TABLE t1 AUTO_INCREMENT=100; + +--connection node_1a +INSERT INTO t1 (f2) SELECT 1 FROM ten; + +--connection node_2a +INSERT INTO t1 (f2) SELECT 1 FROM ten; + +SELECT MIN(f1) = 100, MAX(f1) = 119, COUNT(f1) = 20, COUNT(DISTINCT f1) = 20 FROM t1; + +--connection node_1a +SELECT MIN(f1) = 100, MAX(f1) = 119, COUNT(f1) = 20, COUNT(DISTINCT f1) = 20 FROM t1; + +DROP TABLE t1; + +# +# Restore all variables as they were +# + +--disable_query_log + +--connection node_1 +--eval SET GLOBAL wsrep_auto_increment_control = $auto_increment_control_orig +--eval SET GLOBAL auto_increment_increment = $auto_increment_increment_node1 +--eval SET GLOBAL auto_increment_offset = $auto_increment_offset_node1 + +--connection node_2 +--eval SET GLOBAL wsrep_auto_increment_control = $auto_increment_control_orig +--eval SET GLOBAL auto_increment_increment = $auto_increment_increment_node2 +--eval SET GLOBAL auto_increment_offset = $auto_increment_offset_node2 + +--enable_query_log + +DROP TABLE ten; diff --git a/mysql-test/suite/galera/t/galera_toi_ddl_error.test b/mysql-test/suite/galera/t/galera_toi_ddl_error.test new file mode 100644 index 00000000000..c586d97bdb5 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_toi_ddl_error.test @@ -0,0 +1,29 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc +--source include/big_test.inc + +# +# Test the operation of DDLs that fail partway through +# + +CREATE TABLE ten (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); + +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; + +# Insert 100K rows +INSERT INTO t1 (f1) SELECT (10000 * a1.f1) + (1000 * a2.f1) + (100 * a3.f1) + (10 * a4.f1) + a5.f1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5; + +# Insert one duplicate value +INSERT INTO t1 (f1) SELECT MAX(f1) FROM t1; + +--connection node_2 +--error ER_DUP_ENTRY +ALTER TABLE t1 ADD PRIMARY KEY (f1); +SHOW CREATE TABLE t1; + +--connection node_1 +SHOW CREATE TABLE t1; + +DROP TABLE t1; +DROP TABLE ten; diff --git a/mysql-test/suite/galera/t/galera_toi_ddl_fk_insert.test b/mysql-test/suite/galera/t/galera_toi_ddl_fk_insert.test new file mode 100644 index 00000000000..1f446938775 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_toi_ddl_fk_insert.test @@ -0,0 +1,70 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc +--source include/big_test.inc + +# +# This test creates a new FK constraint while concurrent INSERTS are running +# + +CREATE TABLE ten (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); + +CREATE TABLE parent ( + id INT PRIMARY KEY AUTO_INCREMENT, + f2 INTEGER, + KEY (id) +) ENGINE=InnoDB; + +CREATE TABLE child ( + id INT PRIMARY KEY AUTO_INCREMENT, + parent_id INT +) ENGINE=InnoDB; + +INSERT INTO parent VALUES (DEFAULT, 0); + +--connection node_2 +--send INSERT INTO child (parent_id) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4; + +--let $galera_connection_name = node_1a +--let $galera_server_number = 1 +--source include/galera_connect.inc +--connection node_1a +--send INSERT INTO parent (f2) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4; + +--let $galera_connection_name = node_2a +--let $galera_server_number = 2 +--source include/galera_connect.inc +--connection node_2a +--send INSERT INTO parent (f2) SELECT 2 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4; + +--let $galera_connection_name = node_1b +--let $galera_server_number = 1 +--source include/galera_connect.inc +--connection node_1b +--sleep 2 +--send ALTER TABLE child ADD FOREIGN KEY (parent_id) REFERENCES parent(id); + +--connection node_1a +--reap + +--connection node_1b +--reap + +--connection node_2 +--reap + +--connection node_2a +--reap + +--connection node_1 +SELECT COUNT(*) = 20001 FROM parent; +SELECT COUNT(*) = 10000 FROM child; + +--connection node_2 +SELECT COUNT(*) = 20001 FROM parent; +SELECT COUNT(*) = 10000 FROM child; + +DROP TABLE child; +DROP TABLE parent; + +DROP TABLE ten; diff --git a/mysql-test/suite/galera/t/galera_toi_ddl_locking.test b/mysql-test/suite/galera/t/galera_toi_ddl_locking.test new file mode 100644 index 00000000000..ebab030d9d6 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_toi_ddl_locking.test @@ -0,0 +1,76 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc +--source include/have_debug.inc +--source include/have_debug_sync.inc + +# +# Test that DDL indeed causes all nodes to block so even unrelated updates +# are not allowed to proceed. We block the DDL using DBUG_SYNC +# + +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +CREATE TABLE t2 (f1 INTEGER) ENGINE=InnoDB; + +--connection node_1 +SET DEBUG_SYNC = 'alter_table_before_open_tables WAIT_FOR continue'; +--send ALTER TABLE t1 ADD COLUMN f2 INTEGER; + +--let $galera_connection_name = node_1a +--let $galera_server_number = 1 +--source include/galera_connect.inc + +--let $galera_connection_name = node_1b +--let $galera_server_number = 1 +--source include/galera_connect.inc + +--connection node_1a +SET SESSION wsrep_sync_wait = 0; + +# Allowed +SELECT COUNT(*) = 0 FROM t1; + +# Allowed +SELECT COUNT(*) = 0 FROM t2; + +# Not allowed +--error ER_LOCK_DEADLOCK +INSERT INTO t1 VALUES (1); + +SET AUTOCOMMIT=OFF; +START TRANSACTION; + +# Allowed +INSERT INTO t2 VALUES (1); + +# Hangs +--send COMMIT; +--sleep 1 + +--connection node_1b +SET SESSION wsrep_sync_wait = 0; + +# The Commit issued above is still not done +SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE INFO = 'Commit'; +SELECT COUNT(*) = 0 FROM t2; +SET DEBUG_SYNC= 'now SIGNAL continue'; + +--connection node_1a +--reap + +--connection node_1 +--reap +SELECT COUNT(*) = 0 FROM t1; +SELECT COUNT(*) = 1 FROM t2; + +--connection node_2 +SELECT COUNT(*) = 0 FROM t1; +SELECT COUNT(*) = 1 FROM t2; + +--connection node_1 +SET DEBUG_SYNC= 'RESET'; + +--connection node_1b +SET DEBUG_SYNC= 'RESET'; + +DROP TABLE t1; +DROP TABLE t2; diff --git a/mysql-test/suite/galera/t/galera_toi_ddl_nonconflicting.test b/mysql-test/suite/galera/t/galera_toi_ddl_nonconflicting.test new file mode 100644 index 00000000000..821f7a6eb2c --- /dev/null +++ b/mysql-test/suite/galera/t/galera_toi_ddl_nonconflicting.test @@ -0,0 +1,30 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc + +# +# In this test, we simultaneously send two non-conflicting ALTER TABLE statements +# + +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY AUTO_INCREMENT, f2 INTEGER); + +--connection node_2 +--send ALTER TABLE t1 ADD COLUMN f3 INTEGER; INSERT INTO t1 (f1, f2) VALUES (DEFAULT, 123); + +--connection node_1 +--send CREATE UNIQUE INDEX i1 ON t1(f2); + +--connection node_2 +--reap +INSERT INTO t1 (f1, f2) VALUES (DEFAULT, 234); + +SELECT COUNT(*) = 3 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; +SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_NAME = 't1'; +SELECT COUNT(*) = 2 FROM t1; + +--connection node_1 +--reap +SELECT COUNT(*) = 3 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; +SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_NAME = 't1'; +SELECT COUNT(*) = 2 FROM t1; + +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_toi_ddl_sequential.test b/mysql-test/suite/galera/t/galera_toi_ddl_sequential.test new file mode 100644 index 00000000000..51eae7005df --- /dev/null +++ b/mysql-test/suite/galera/t/galera_toi_ddl_sequential.test @@ -0,0 +1,29 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc + +# +# In this test, we send two ALTER TABLE statements that would only work if executed in the right order +# + +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); + +--connection node_2 +ALTER TABLE t1 ADD COLUMN f2 INTEGER; +INSERT INTO t1 VALUES (2, 3); + +--connection node_1 +ALTER TABLE t1 DROP COLUMN f2; +INSERT INTO t1 VALUES (4); + +--connection node_2 +SHOW CREATE TABLE t1; +SELECT COUNT(*) = 3 FROM t1; +SELECT * FROM t1 ORDER BY f1; + +--connection node_1 +SHOW CREATE TABLE t1; +SELECT COUNT(*) = 3 FROM t1; +SELECT * FROM t1 ORDER BY f1; + +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_toi_ftwrl.test b/mysql-test/suite/galera/t/galera_toi_ftwrl.test new file mode 100644 index 00000000000..4d0edefda8e --- /dev/null +++ b/mysql-test/suite/galera/t/galera_toi_ftwrl.test @@ -0,0 +1,22 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc + +# +# At this time, issing a FLUSH TABLES WITH READ LOCK on one node does not prevent DDLs from other nodes +# from proceeding. The locked node will apply the DDL after it has been unlocked +# + +CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB; + +--connection node_2 +FLUSH TABLES WITH READ LOCK; + +--connection node_1 +ALTER TABLE t1 ADD COLUMN f2 INTEGER; + +--connection node_2 +UNLOCK TABLES; +SHOW CREATE TABLE t1; + +DROP TABLE t1; + diff --git a/mysql-test/suite/galera/t/galera_toi_lock_exclusive.test b/mysql-test/suite/galera/t/galera_toi_lock_exclusive.test new file mode 100644 index 00000000000..3c66286a3e6 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_toi_lock_exclusive.test @@ -0,0 +1,38 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc + +# +# Ensure that ALTER LOCK=EXCLUSIVE works under TOI. It is difficult to check that concurrent operations +# are truly not possible, but at least we expect no hangs or deadlocks +# + +CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); + +# Start a transaction that is concurrent to the DDL. This is not strictly necessary for this test +# but does put more locks into play. +--connection node_2 +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (2); + +--let $galera_connection_name = node_2a +--let $galera_server_number = 2 +--source include/galera_connect.inc +--connection node_2a +ALTER TABLE t1 ADD COLUMN f2 INTEGER, LOCK=EXCLUSIVE; + +# In Galera, a concurrent transaction aborts in the face of ALTER +--connection node_2 +--error ER_LOCK_DEADLOCK +COMMIT; + +--connection node_1 +INSERT INTO t1 VALUES (2, 2); +SELECT COUNT(*) = 2 FROM t1; + +--connection node_2 +INSERT INTO t1 VALUES (3, 3); +SELECT COUNT(*) = 3 FROM t1; + +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_toi_lock_shared.test b/mysql-test/suite/galera/t/galera_toi_lock_shared.test new file mode 100644 index 00000000000..6857a0e08ca --- /dev/null +++ b/mysql-test/suite/galera/t/galera_toi_lock_shared.test @@ -0,0 +1,23 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc + +# +# Ensure that ALTER LOCK=SHARED works under TOI. It is difficult to check that concurrent operations +# will be possible, but at least we expect no hangs or deadlocks +# + +CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); + +--connection node_2 +ALTER TABLE t1 ADD COLUMN f2 INTEGER, LOCK=SHARED; + +--connection node_1 +INSERT INTO t1 VALUES (2, 2); +SELECT COUNT(*) = 2 FROM t1; + +--connection node_2 +INSERT INTO t1 VALUES (3, 3); +SELECT COUNT(*) = 3 FROM t1; + +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_transaction_read_only.test b/mysql-test/suite/galera/t/galera_transaction_read_only.test new file mode 100644 index 00000000000..386d73fd3ca --- /dev/null +++ b/mysql-test/suite/galera/t/galera_transaction_read_only.test @@ -0,0 +1,58 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc + +# +# Ensure that transactions that do not write anything do not cause the wsrep_last_committed counter to advance +# + +# Empty transaction + +--connection node_1 +CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB; + +--connection node_2 +--let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` + +--connection node_1 + +SET AUTOCOMMIT=OFF; +START TRANSACTION; +COMMIT; + +--connection node_2 +--let $wsrep_last_committed_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` +--disable_query_log +--eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before AS wsrep_last_committed_diff; +--enable_query_log + +# START TRANSACTION READ ONLY + +--connection node_2 +--let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` + +--connection node_1 +START TRANSACTION READ ONLY; +SELECT COUNT(*) = 0 FROM t1; +COMMIT; + +--connection node_2 +--let $wsrep_last_committed_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` +--disable_query_log +--eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before AS wsrep_last_committed_diff; +--enable_query_log + +# Ordinary transaction with only SELECTs + +--connection node_1 +START TRANSACTION; +SELECT COUNT(*) = 0 FROM t1; +COMMIT; + +--connection node_2 +--let $wsrep_last_committed_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` +--disable_query_log +--eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before AS wsrep_last_committed_diff; +--enable_query_log + +DROP TABLE t1; + diff --git a/mysql-test/suite/galera/t/galera_transaction_replay.test b/mysql-test/suite/galera/t/galera_transaction_replay.test new file mode 100644 index 00000000000..d2c74ab192b --- /dev/null +++ b/mysql-test/suite/galera/t/galera_transaction_replay.test @@ -0,0 +1,63 @@ +# +# This test tests the operation of transaction replay. If a potentially conflicting remote transaction arrives at +# just the right time during the commit of a local transaction, the local transaction will be aborted and replayed. +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc +--source include/have_debug_sync.inc +--source suite/galera/include/galera_have_debug_sync.inc + +--let $wsrep_local_replays_old = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_replays'` + +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 CHAR(1)); +INSERT INTO t1 VALUES (1, 'a'); +INSERT INTO t1 VALUES (2, 'a'); + +--connection node_1 +SET AUTOCOMMIT=ON; +START TRANSACTION; + +UPDATE t1 SET f2 = 'b' WHERE f1 = 1; +SELECT * FROM t1 WHERE f1 = 2 FOR UPDATE; + +# Block the commit +--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1 +SET GLOBAL wsrep_provider_options = 'dbug=d,apply_monitor_enter_sync'; + +--connection node_1 +--send COMMIT; + +# Wait until commit is blocked +--connection node_1a +SET SESSION wsrep_sync_wait = 0; +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_debug_sync_waiters' AND VARIABLE_VALUE = 'apply_monitor_enter_sync' +--source include/wait_condition.inc + +# Issue a conflicting update on node #2 +--connection node_2 +UPDATE t1 SET f2 = 'c' WHERE f1 = 2; + +# Unblock the commit +--connection node_1a +SET GLOBAL wsrep_provider_options = 'dbug='; +SET GLOBAL wsrep_provider_options = 'signal=apply_monitor_enter_sync'; + +# Commit succeeds +--connection node_1 +--reap + +SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'b'; +SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'c'; + +# wsrep_local_replays has increased by 1 +--let $wsrep_local_replays_new = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_replays'` +--disable_query_log +--eval SELECT $wsrep_local_replays_new - $wsrep_local_replays_old = 1 AS wsrep_local_replays; +--enable_query_log + +--connection node_2 +SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'b'; +SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'c'; + +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_truncate.test b/mysql-test/suite/galera/t/galera_truncate.test new file mode 100644 index 00000000000..79f9bad1f1b --- /dev/null +++ b/mysql-test/suite/galera/t/galera_truncate.test @@ -0,0 +1,57 @@ +# +# Test TRUNCATE +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +# +# Simple case +# + +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) Engine=InnoDB; + +INSERT INTO t1 VALUES (1); + +--connection node_2 +TRUNCATE TABLE t1; +SELECT COUNT(*) = 0 FROM t1; + +--connection node_1 +SELECT COUNT(*) = 0 FROM t1; + +# +# Table with no PK +# + +--connection node_2 +CREATE TABLE t2 (f1 VARCHAR(255)) Engine=InnoDB; +INSERT INTO t2 VALUES ('abc'); + +--connection node_1 +TRUNCATE TABLE t2; + +--connection node_2 +SELECT COUNT(*) = 0 FROM t2; + +# +# Table with AUTO_INCREMENT. The AUTO_INCREMENT counter must be reset on all nodes +# + +--connection node_1 +CREATE TABLE t3 (f1 INTEGER AUTO_INCREMENT PRIMARY KEY) Engine=InnoDB; +INSERT INTO t3 VALUES (DEFAULT),(DEFAULT),(DEFAULT),(DEFAULT),(DEFAULT); + +CREATE TABLE t4 (f1 INTEGER AUTO_INCREMENT PRIMARY KEY) Engine=InnoDB AUTO_INCREMENT=1234; +INSERT INTO t4 VALUES (DEFAULT),(DEFAULT),(DEFAULT),(DEFAULT),(DEFAULT); + +TRUNCATE TABLE t3; +TRUNCATE TABLE t4; + +--connection node_2 +SELECT AUTO_INCREMENT = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME IN ('t3', 't4'); + +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE t3; +DROP TABLE t4; diff --git a/mysql-test/suite/galera/t/galera_truncate_temporary.test b/mysql-test/suite/galera/t/galera_truncate_temporary.test new file mode 100644 index 00000000000..3ad94eb9930 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_truncate_temporary.test @@ -0,0 +1,82 @@ +# +# Test TRUNCATE on TEMPORARY tables. It should not be replicated +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +CREATE TEMPORARY TABLE t1 (f1 INTEGER PRIMARY KEY) Engine=InnoDB; + +INSERT INTO t1 VALUES (1); + +TRUNCATE TABLE t1; +SELECT COUNT(*) = 0 FROM t1; + +--connection node_2 +--error ER_NO_SUCH_TABLE +SELECT * FROM t1; + +--connection node_1 +DROP TABLE t1; + +# +# Test the case where a TEMPORARY table is masking an existing one +# + +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); + +CREATE TEMPORARY TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 VALUES (2); + +SELECT f1 = 2 FROM t1; +SELECT COUNT(*) = 1 FROM t1; + +TRUNCATE TABLE t1; + +SELECT COUNT(*) = 0 FROM t1; + +--connection node_2 +SELECT COUNT(*) = 1 FROM t1; +SELECT f1 = 1 FROM t1; + +--connection node_1 + +DROP TABLE t1; +SELECT COUNT(*) = 1 FROM t1; +SELECT f1 = 1 FROM t1; + +TRUNCATE TABLE t1; +SELECT COUNT(*) = 0 FROM t1; + +--connection node_2 +SELECT COUNT(*) = 0 FROM t1; + +--connection node_1 +DROP TABLE t1; + +# +# Test the case where one node has a TEMPORARY table but the TRUNCATE arrives from another node +# + +--connection node_1 +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); + +CREATE TEMPORARY TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 VALUES (2); + +--connection node_2 +TRUNCATE TABLE t1; + +SELECT COUNT(*) = 0 FROM t1; + +--connection node_1 +SELECT f1 = 2 FROM t1; +SELECT COUNT(*) = 1 FROM t1; + +DROP TABLE t1; + +SELECT COUNT(*) = 0 FROM t1; + +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_udf-master.opt b/mysql-test/suite/galera/t/galera_udf-master.opt new file mode 100644 index 00000000000..14dfe3e20bc --- /dev/null +++ b/mysql-test/suite/galera/t/galera_udf-master.opt @@ -0,0 +1,2 @@ +$UDF_EXAMPLE_LIB_OPT +--query_cache_type=1 diff --git a/mysql-test/suite/galera/t/galera_unicode_identifiers.test b/mysql-test/suite/galera/t/galera_unicode_identifiers.test index 4722d6d61a2..2f255e9a197 100644 --- a/mysql-test/suite/galera/t/galera_unicode_identifiers.test +++ b/mysql-test/suite/galera/t/galera_unicode_identifiers.test @@ -21,7 +21,7 @@ CREATE TABLE `table with space` ( `column with space` INTEGER AUTO_INCREMENT PRIMARY KEY, `second column with space` INTEGER, UNIQUE `index name with space` (`second column with space`) -) ENGINE=INNODB; +); INSERT INTO `table with space` VALUES (DEFAULT, 1); # Unicode identifiers @@ -32,7 +32,7 @@ CREATE TABLE `таблица` ( `първа_колона` INTEGER PRIMARY KEY, `втора_колона` INTEGER, UNIQUE `индекс` (`втора_колона`) -) ENGINE=INNODB; +); INSERT INTO `таблица` VALUES (1, 1); @@ -44,19 +44,19 @@ CREATE TABLE `втора таблица` ( `първа колона` INTEGER, `втора колона` INTEGER, KEY `първи индекс` (`първа колона`) -) ENGINE=INNODB; +); INSERT INTO `втора таблица` VALUES (1, 1); --connection node_2 USE `database with space`; -SELECT * FROM `table with space`; +SELECT `second column with space` FROM `table with space`; USE `база`; SELECT * FROM `таблица`; USE `втора база`; -SELECT * FROM `втора таблица`; +SELECT `втора колона` FROM `втора таблица`; --eval SET GLOBAL wsrep_sync_wait = $wsrep_sync_wait_orig diff --git a/mysql-test/suite/galera/t/galera_unicode_pk.test b/mysql-test/suite/galera/t/galera_unicode_pk.test new file mode 100644 index 00000000000..0d571f5cfd7 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_unicode_pk.test @@ -0,0 +1,64 @@ +# +# Test non-ascii data in table where the PK is unicode +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +CREATE TABLE t1 ( + f1 VARCHAR(255) PRIMARY KEY +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +INSERT INTO t1 VALUES ('текст'); + +--connection node_2 +SELECT f1 = 'текст' FROM t1; + +# +# Provoke a conflict +# + +--connection node_1 +SET AUTOCOMMIT=OFF; +START TRANSACTION; +UPDATE t1 SET f1 = 'текст2'; + +--connection node_2 +SET AUTOCOMMIT=OFF; +START TRANSACTION; +UPDATE t1 SET f1 = 'текст3'; + +--connection node_1 +COMMIT; + +--connection node_2 +--error ER_LOCK_DEADLOCK +COMMIT; + +SELECT f1 = 'текст2' FROM t1; +SELECT f1 = 'текст2' FROM t1 WHERE f1 = 'текст2'; + +# +# Provoke a duplicate key error +# + +--connection node_2 +START TRANSACTION; +INSERT INTO t1 VALUES ('текст4'); + +--connection node_1 +START TRANSACTION; +INSERT INTO t1 VALUES ('текст4'); + +--connection node_2 +COMMIT; + +--connection node_1 +--error ER_LOCK_DEADLOCK +COMMIT; + +# Work around for mysql-wsrep#29 'Spurious deadlock error on a DROP TABLE' +--error 0,ER_LOCK_DEADLOCK +COMMIT; + +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_update_limit.test b/mysql-test/suite/galera/t/galera_update_limit.test new file mode 100644 index 00000000000..baacf2a60b2 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_update_limit.test @@ -0,0 +1,55 @@ +# +# UPDATE LIMIT should not cause any issues with row-based Galera replication +# regardless of the order in which the rows were updated +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +# +# With a PK +# + +--connection node_1 +CREATE TABLE ten (f1 INTEGER) Engine=InnoDB; +INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); + +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) Engine=InnoDB; +INSERT INTO t1 SELECT f1 FROM ten ORDER BY RAND(); + +--connection node_2 +UPDATE IGNORE t1 SET f1 = FLOOR(1 + (RAND() * 10)) ORDER BY RAND() LIMIT 5; + +# Check that the sum of all elements and the max element are identical across nodes +# as this will indicate that the same UPDATE was applied to both nodes + +--let $sum_rows = `SELECT SUM(f1) FROM t1` +--let $max_row = `SELECT MAX(f1) FROM t1` + +--connection node_1 +--disable_query_log +--eval SELECT (SELECT SUM(f1) FROM t1) = $sum_rows AS sum_matches; +--eval SELECT f1 = $max_row AS max_matches FROM t1 WHERE f1 = $max_row; +--enable_query_log + +DROP TABLE t1; + +# +# Without a PK +# + +CREATE TABLE t2 (f1 INTEGER) Engine=InnoDB; +INSERT INTO t2 SELECT f1 FROM ten ORDER BY RAND(); + +--connection node_2 +UPDATE IGNORE t2 SET f1 = FLOOR(1 + (RAND() * 10)) ORDER BY RAND() LIMIT 5; + +--let $sum_rows = `SELECT SUM(f1) FROM t2` + +--connection node_1 +--disable_query_log +--eval SELECT (SELECT SUM(f1) FROM t2) = $sum_rows AS sum_matches; +--enable_query_log + +DROP TABLE t2; +DROP TABLE ten; diff --git a/mysql-test/suite/galera/t/galera_v1_row_events-master.opt b/mysql-test/suite/galera/t/galera_v1_row_events-master.opt new file mode 100644 index 00000000000..dc82542128e --- /dev/null +++ b/mysql-test/suite/galera/t/galera_v1_row_events-master.opt @@ -0,0 +1 @@ +--log-bin-use-v1-row-events=1 diff --git a/mysql-test/suite/galera/t/galera_v1_row_events.test b/mysql-test/suite/galera/t/galera_v1_row_events.test new file mode 100644 index 00000000000..0c0a044510e --- /dev/null +++ b/mysql-test/suite/galera/t/galera_v1_row_events.test @@ -0,0 +1,21 @@ +# +# Test that Galera continues to run even with --log-bin-use-v1-row-events=1 +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +CREATE TABLE t1 (f1 INT PRIMARY KEY) ENGINE=InnoDB; + +INSERT INTO t1 VALUES (1); + +--connection node_2 +SELECT COUNT(*) = 1 FROM t1; + +--connection node_1 +UPDATE t1 SET f1 = 2 WHERE f1 = 1; + +--connection node_2 +SELECT COUNT(*) = 1 FROM t1 WHERE f1 = 2; + +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_var_OSU_method.test b/mysql-test/suite/galera/t/galera_var_OSU_method.test index 6190d5cec9a..fcf964c4f89 100644 --- a/mysql-test/suite/galera/t/galera_var_OSU_method.test +++ b/mysql-test/suite/galera/t/galera_var_OSU_method.test @@ -36,4 +36,10 @@ SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; --connection node_1 SET SESSION wsrep_OSU_method = "TOI"; +--connection node_1 +SET DEBUG_SYNC= 'RESET'; + +--connection node_1a +SET DEBUG_SYNC= 'RESET'; + DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_var_OSU_method2.test b/mysql-test/suite/galera/t/galera_var_OSU_method2.test index abc01ee3e0e..099e2cc6612 100644 --- a/mysql-test/suite/galera/t/galera_var_OSU_method2.test +++ b/mysql-test/suite/galera/t/galera_var_OSU_method2.test @@ -40,4 +40,8 @@ INSERT INTO t1 VALUES (3,4); --connection node_1 SET GLOBAL wsrep_OSU_method = "TOI"; DROP TABLE t1; +SET DEBUG_SYNC= 'RESET'; + +--connection node_1a +SET DEBUG_SYNC= 'RESET'; diff --git a/mysql-test/suite/galera/t/galera_var_auto_inc_control_off.test b/mysql-test/suite/galera/t/galera_var_auto_inc_control_off.test index 1ae08abc920..c0bbe5af8cf 100644 --- a/mysql-test/suite/galera/t/galera_var_auto_inc_control_off.test +++ b/mysql-test/suite/galera/t/galera_var_auto_inc_control_off.test @@ -88,6 +88,8 @@ SELECT * FROM t1; # Restore all variables as they were # +--disable_query_log + --connection node_1 --eval SET GLOBAL wsrep_auto_increment_control = $auto_increment_control_orig --eval SET GLOBAL auto_increment_increment = $auto_increment_increment_node1 @@ -98,4 +100,6 @@ SELECT * FROM t1; --eval SET GLOBAL auto_increment_increment = $auto_increment_increment_node2 --eval SET GLOBAL auto_increment_offset = $auto_increment_offset_node2 +--enable_query_log + DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_var_auto_inc_control_on.test b/mysql-test/suite/galera/t/galera_var_auto_inc_control_on.test index 4d1b9af1573..59f2615b685 100644 --- a/mysql-test/suite/galera/t/galera_var_auto_inc_control_on.test +++ b/mysql-test/suite/galera/t/galera_var_auto_inc_control_on.test @@ -9,13 +9,11 @@ CREATE TABLE t1 (f1 INTEGER AUTO_INCREMENT PRIMARY KEY, node VARCHAR(10)) ENGINE=InnoDB; -SHOW CREATE TABLE t1; - # auto_increment_increment is equal to the number of nodes # auto_increment_offset is equal to the ID of the node SELECT @@auto_increment_increment = (SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'); -SELECT @@auto_increment_offset = 1; +SELECT @@auto_increment_offset = (SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_index') + 1; # Expect no conflicts --send INSERT INTO t1 VALUES (DEFAULT, 'node1'); @@ -29,9 +27,8 @@ SELECT @@auto_increment_offset = 1; --connection node_2 --reap -SHOW CREATE TABLE t1; SELECT @@auto_increment_increment = (SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'); -SELECT @@auto_increment_offset = 2; +SELECT @@auto_increment_offset = (SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_index') + 1; # Expect no conflicts --send INSERT INTO t1 VALUES (DEFAULT, 'node2'), (DEFAULT, 'node2'), (DEFAULT, 'node2'), (DEFAULT, 'node2'), (DEFAULT, 'node2'), (DEFAULT, 'node2'), (DEFAULT, 'node2'), (DEFAULT, 'node2'), (DEFAULT, 'node2'), (DEFAULT, 'node2'); diff --git a/mysql-test/suite/galera/t/galera_var_cluster_address.test b/mysql-test/suite/galera/t/galera_var_cluster_address.test new file mode 100644 index 00000000000..f53986c49b8 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_var_cluster_address.test @@ -0,0 +1,105 @@ +# +# Check the handling of @@wsrep_cluster_address +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +# +# Set to invalid value +# + +--connection node_1 +--let $wsrep_cluster_address_node1 = `SELECT @@wsrep_cluster_address` +SET GLOBAL wsrep_cluster_address = 'foo://'; + +# With wsrep_sync_wait, this returns an error +#--error ER_LOCK_WAIT_TIMEOUT +#SHOW STATUS; + +SET SESSION wsrep_sync_wait=0; + +--error ER_UNKNOWN_COM_ERROR +SELECT * FROM INFORMATION_SCHEMA.GLOBAL_STATUS; + +# Must return 'OFF' +SHOW STATUS LIKE 'wsrep_ready'; + +# Must return 'Non-primary' +SHOW STATUS LIKE 'wsrep_cluster_status'; + +# Must return 0 = 'Initialized' +SHOW STATUS LIKE 'wsrep_local_state'; +SHOW STATUS LIKE 'wsrep_local_state_comment'; + +--connection node_2 +--sleep 1 +# Node #2 thinks that it is now part of a single-node primary cluster +SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; + +# +# Reset everything as it was +# + +--connection node_1 +--disable_query_log +--eval SET GLOBAL wsrep_cluster_address = '$wsrep_cluster_address_node1'; +--enable_query_log + +--connection node_2 +SET GLOBAL wsrep_cluster_address = @@wsrep_cluster_address; + +--source include/wait_until_connected_again.inc + +--connection node_1 +SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; + +# +# Set to invalid host +# + +--connection node_1 +SET GLOBAL wsrep_cluster_address = 'gcomm://192.0.2.1'; + +--error ER_UNKNOWN_COM_ERROR +SELECT * FROM INFORMATION_SCHEMA.GLOBAL_STATUS; + +# Must return 'OFF' +SHOW STATUS LIKE 'wsrep_ready'; + +# Must return 'Non-primary' +SHOW STATUS LIKE 'wsrep_cluster_status'; + +# Must return 0 = 'Initialized' +SHOW STATUS LIKE 'wsrep_local_state'; +SHOW STATUS LIKE 'wsrep_local_state_comment'; + +# +# Reset everything as it was +# + +--connection node_1 +--disable_query_log +--eval SET GLOBAL wsrep_cluster_address = '$wsrep_cluster_address_node1'; +--enable_query_log + +--connection node_2 +SET GLOBAL wsrep_cluster_address = @@wsrep_cluster_address; +--sleep 1 + +--connection node_1 +SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; + +CALL mtr.add_suppression("WSREP: .*Backend not supported: foo.*"); +CALL mtr.add_suppression("WSREP: .*Failed to initialize backend using 'foo.*"); +CALL mtr.add_suppression("WSREP: .*Failed to open channel 'my_wsrep_cluster' at 'foo*"); +CALL mtr.add_suppression("WSREP: gcs connect failed: Socket type not supported"); +CALL mtr.add_suppression("WSREP: failed to open gcomm backend connection: 110: failed to reach primary view: 110 \\(Connection timed out\\)"); +CALL mtr.add_suppression("WSREP: .*Failed to open backend connection: -110 \\(Connection timed out\\)"); +CALL mtr.add_suppression("WSREP: .*Failed to open channel 'my_wsrep_cluster' at 'gcomm://192\\.0\\.2\\.1': -110 \\(Connection timed out\\)"); +CALL mtr.add_suppression("WSREP: gcs connect failed: Connection timed out"); +CALL mtr.add_suppression("WSREP: wsrep::connect\\(\\) failed: 7"); +#CALL mtr.add_suppression("gcs_caused\\(\\) returned -103 \\(Software caused connection abort\\)"); diff --git a/mysql-test/suite/galera/t/galera_var_desync_on.test b/mysql-test/suite/galera/t/galera_var_desync_on.test new file mode 100644 index 00000000000..fb0fb9f762a --- /dev/null +++ b/mysql-test/suite/galera/t/galera_var_desync_on.test @@ -0,0 +1,58 @@ +# +# Test wsrep_desync = ON . Node should temporarily not participate in flow control +# so even if fc_limit has been reached, the master should be able to continue to +# commit transactions. +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); + +--connection node_2 +--let $wsrep_provider_options_orig = `SELECT @@wsrep_provider_options` +SET GLOBAL wsrep_provider_options = 'gcs.fc_limit=1'; +SET GLOBAL wsrep_desync = TRUE; + +# Block the slave applier thread +FLUSH TABLES WITH READ LOCK; + +--connection node_1 + +# Without wsrep_desync = TRUE it would not be possible to perform 10 inserts on the master with gcs.fc_limit=1 +INSERT INTO t1 VALUES (2); +INSERT INTO t1 VALUES (3); +INSERT INTO t1 VALUES (4); +INSERT INTO t1 VALUES (5); +INSERT INTO t1 VALUES (6); +INSERT INTO t1 VALUES (7); +INSERT INTO t1 VALUES (8); +INSERT INTO t1 VALUES (9); +INSERT INTO t1 VALUES (10); +--sleep 1 + +--connection node_2 +SET SESSION wsrep_sync_wait = 0; +# No updates have arrived after the FLUSH TABLES +SELECT COUNT(*) = 1 FROM t1; + +# Resync the slave +SET GLOBAL wsrep_desync = FALSE; +--disable_query_log +--eval SET GLOBAL wsrep_provider_options = '$wsrep_provider_options_orig'; +--enable_query_log +UNLOCK TABLES; + +SET SESSION wsrep_sync_wait = 1; +# The slave is now fully caught up +SELECT COUNT(*) = 10 FROM t1; + +--connection node_1 +INSERT INTO t1 VALUES (11); + +--connection node_2 +# Replication continues normally +SELECT COUNT(*) = 11 FROM t1; + +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_var_innodb_disallow_writes.test b/mysql-test/suite/galera/t/galera_var_innodb_disallow_writes.test new file mode 100644 index 00000000000..c08483b63ad --- /dev/null +++ b/mysql-test/suite/galera/t/galera_var_innodb_disallow_writes.test @@ -0,0 +1,33 @@ +# +# This test checks that innodb_disallow_writes works as expected +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +# Open a separate connection to be used to run SHOW PROCESSLIST +--let $galera_connection_name = node_1a +--let $galera_server_number = 1 +--source include/galera_connect.inc +--connection node_1a +SET SESSION wsrep_sync_wait = 0; + +--connection node_1 +CREATE TABLE t1 (f1 INTEGER) Engine=InnoDB; +SET GLOBAL innodb_disallow_writes=ON; +--send INSERT INTO t1 VALUES (1); + +--connection node_1a +let $wait_condition = SELECT 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE INFO = 'INSERT INTO t1 VALUES (1)' AND State = 'query end'; +--source include/wait_condition.inc + +SET GLOBAL innodb_disallow_writes=OFF; + +--connection node_1 +--reap +SELECT COUNT(*) = 1 FROM t1; + +--connection node_2 +SELECT COUNT(*) = 1 FROM t1; + +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_var_load_data_splitting.test b/mysql-test/suite/galera/t/galera_var_load_data_splitting.test new file mode 100644 index 00000000000..0783dc897f8 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_var_load_data_splitting.test @@ -0,0 +1,38 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc + +--let $wsrep_load_data_splitting_orig = `SELECT @@wsrep_load_data_splitting` + +# Create a file for LOAD DATA with 95K entries +--perl +open(FILE, ">", "$ENV{'MYSQLTEST_VARDIR'}/tmp/galera_var_load_data_splitting.csv") or die; +foreach my $i (1..95000) { + print FILE "$i\n"; +} +EOF + +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; + +# Record wsrep_last_committed as it was before LOAD DATA +--connection node_2 +--let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` + +SET GLOBAL wsrep_load_data_splitting = TRUE; +--disable_query_log +--eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/galera_var_load_data_splitting.csv' INTO TABLE t1; +--enable_query_log + +--connection node_2 +--let $wsrep_last_committed_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` + +SELECT COUNT(*) = 95000 FROM t1; + +# LOAD-ing 95K rows causes 10 commits to be registered +--disable_query_log +--eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before + 10 AS wsrep_last_committed_diff; +--enable_query_log + +--connection node_1 +--eval SET GLOBAL wsrep_load_data_splitting = $wsrep_load_data_splitting_orig; + +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_var_max_ws_size.test b/mysql-test/suite/galera/t/galera_var_max_ws_size.test new file mode 100644 index 00000000000..720f9be8a99 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_var_max_ws_size.test @@ -0,0 +1,27 @@ +# +# This test sets wsrep_max_ws_size to a very low value and checks that the transaction is rejected +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +--connection node_1 +call mtr.add_suppression('WSREP: transaction size limit.*'); +call mtr.add_suppression('WSREP: rbr write fail.*'); +call mtr.add_suppression('WSREP: Maximum writeset size exceeded by.*'); +call mtr.add_suppression('WSREP: transaction size exceeded.*'); + +CREATE TABLE t1 (f1 INTEGER AUTO_INCREMENT PRIMARY KEY, f2 VARCHAR(1024)) Engine=InnoDB; + +--let $wsrep_max_ws_size_orig = `SELECT @@wsrep_max_ws_size` +SET GLOBAL wsrep_max_ws_size = 1024; + +--error ER_ERROR_DURING_COMMIT +INSERT INTO t1 VALUES (DEFAULT, REPEAT('X', 1024)); +SELECT COUNT(*) = 0 FROM t1; + +--disable_query_log +--eval SET GLOBAL wsrep_max_ws_size = $wsrep_max_ws_size_orig +--enable_query_log + +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_var_notify_cmd-master.opt b/mysql-test/suite/galera/t/galera_var_notify_cmd-master.opt new file mode 100644 index 00000000000..70dfc98736b --- /dev/null +++ b/mysql-test/suite/galera/t/galera_var_notify_cmd-master.opt @@ -0,0 +1 @@ +--wsrep_notify_cmd=$MYSQL_TEST_DIR/std_data/wsrep_notify.sh --wsrep-sync-wait=0 diff --git a/mysql-test/suite/galera/t/galera_var_notify_cmd.test b/mysql-test/suite/galera/t/galera_var_notify_cmd.test new file mode 100644 index 00000000000..4fea69f62bb --- /dev/null +++ b/mysql-test/suite/galera/t/galera_var_notify_cmd.test @@ -0,0 +1,14 @@ +# +# Test wsrep_notify_cmd. We use a version of the support-files/wsrep_notify.sh script that writes +# notifications into a table. +# + +--source include/have_innodb.inc +--source include/galera_cluster.inc + +--connection node_1 +SELECT COUNT(DISTINCT uuid) = 2 FROM mtr_wsrep_notify.membership; +SELECT MAX(size) = 2 FROM mtr_wsrep_notify.status; +SELECT COUNT(DISTINCT idx) = 2 FROM mtr_wsrep_notify.status; + +DROP SCHEMA mtr_wsrep_notify; diff --git a/mysql-test/suite/galera/t/galera_var_replicate_myisam_on.test b/mysql-test/suite/galera/t/galera_var_replicate_myisam_on.test index f6838028e66..9cb0edf1810 100644 --- a/mysql-test/suite/galera/t/galera_var_replicate_myisam_on.test +++ b/mysql-test/suite/galera/t/galera_var_replicate_myisam_on.test @@ -5,17 +5,135 @@ --source include/galera_cluster.inc --source include/have_innodb.inc +--connection node_1 --let $wsrep_replicate_myisam_orig = `SELECT @@wsrep_replicate_myisam` +--connection node_1 SET GLOBAL wsrep_replicate_myisam = TRUE; +--connection node_2 +SET GLOBAL wsrep_replicate_myisam = TRUE; + +# +# Simple INSERT +# +--connection node_1 CREATE TABLE t1 (f1 INT PRIMARY KEY) Engine=MyISAM; INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (2), (3); +INSERT INTO t1 SELECT 4 FROM DUAL UNION ALL SELECT 5 FROM DUAL; + +--connection node_2 +SELECT COUNT(*) = 5 FROM t1; + +DROP TABLE t1; + +# +# REPLACE +# + +--connection node_1 +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 VARCHAR(100)) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1, 'abc'),(2,'abc'), (3, 'xxx'); +REPLACE INTO t1 VALUES (1, 'klm'), (2,'xyz'); +REPLACE INTO t1 SELECT 3, 'yyy' FROM DUAL; + +--connection node_2 +SELECT COUNT(*) = 3 FROM t1; +SELECT COUNT(*) = 1 FROM t1 WHERE f1 = 1 AND f2 = 'klm'; +SELECT COUNT(*) = 1 FROM t1 WHERE f1 = 2 AND f2 = 'xyz'; +SELECT COUNT(*) = 1 FROM t1 WHERE f1 = 3 AND f2 = 'yyy'; + +# +# UPDATE +# + +--connection node_1 +UPDATE t1 SET f2 = 'zzz' WHERE f2 = 'yyy'; + +--connection node_2 +SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'zzz'; + +# +# DELETE +# + +--connection node_1 +DELETE FROM t1 WHERE f2 = 'zzz'; + +--connection node_2 +SELECT COUNT(*) = 0 FROM t1 WHERE f2 = 'zzz'; + +# +# TRUNCATE +# + +--connection node_1 +TRUNCATE TABLE t1; + +--connection node_2 +SELECT COUNT(*) = 0 FROM t1; +DROP TABLE t1; + +# +# Transaction +# + +--connection node_1 +CREATE TABLE t1 (f1 INTEGER) ENGINE=MyISAM; +CREATE TABLE t2 (f1 INTEGER) ENGINE=InnoDB; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1); +COMMIT; --connection node_2 SELECT COUNT(*) = 1 FROM t1; +SELECT COUNT(*) = 1 FROM t2; + +# +# Transaction rollback +# --connection node_1 ---eval SET GLOBAL wsrep_replicate_myisam = $wsrep_replicate_myisam_orig +START TRANSACTION; +INSERT INTO t1 VALUES (2); +INSERT INTO t2 VALUES (2); +ROLLBACK; + +--connection node_2 +SELECT COUNT(*) = 2 FROM t1; +SELECT COUNT(*) = 1 FROM t2; + +DROP TABLE t1; +DROP TABLE t2; + +# +# Transaction conflict +# + +--connection node_1 +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=MyISAM; +CREATE TABLE t2 (f2 INTEGER PRIMARY KEY) ENGINE=InnoDB; + +START TRANSACTION; +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (1); + +--connection node_2 +# The MyISAM update is replicated immediately, so a duplicate key error happens even before the COMMIT +--error ER_DUP_ENTRY +INSERT INTO t1 VALUES (1); + +--connection node_1 +COMMIT; DROP TABLE t1; +DROP TABLE t2; + +--connection node_1 +--eval SET GLOBAL wsrep_replicate_myisam = $wsrep_replicate_myisam_orig + +--connection node_2 +--eval SET GLOBAL wsrep_replicate_myisam = $wsrep_replicate_myisam_orig diff --git a/mysql-test/suite/galera/t/galera_var_slave_threads.test b/mysql-test/suite/galera/t/galera_var_slave_threads.test new file mode 100644 index 00000000000..a83924c13ce --- /dev/null +++ b/mysql-test/suite/galera/t/galera_var_slave_threads.test @@ -0,0 +1,70 @@ +# +# This tests the very basic operations around wsrep-slave-threads +# More complex scenarios will be tested separately in the context of +# parallel replication +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +--let $wsrep_slave_threads_orig = `SELECT @@wsrep_slave_threads` + +--connection node_1 +CREATE TABLE t1 (f1 INT PRIMARY KEY) Engine=InnoDB; +CREATE TABLE t2 (f1 INT AUTO_INCREMENT PRIMARY KEY) Engine=InnoDB; + +--connection node_2 + +# Setting wsrep_slave_threads to zero triggers a warning +SET GLOBAL wsrep_slave_threads = 0; +SHOW WARNINGS; +SELECT @@wsrep_slave_threads = 1; + +SET GLOBAL wsrep_slave_threads = 1; +# There is a separate wsrep_aborter thread at all times +SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user'; +SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE LIKE '%wsrep aborter%'; + +# +# Increase the number of slave threads. The change takes effect immediately +# + +SET GLOBAL wsrep_slave_threads = 64; +--sleep 0.5 + +--connection node_1 +INSERT INTO t1 VALUES (1); + +--connection node_2 +SELECT COUNT(*) = 1 FROM t1; + +SELECT COUNT(*) = @@wsrep_slave_threads + 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user'; +SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE LIKE '%wsrep aborter%'; + +# +# Reduce the number of slave threads. The change is not immediate -- a thread will only exit after a replication event +# + +SET GLOBAL wsrep_slave_threads = 1; + +--connection node_1 + +# Generate 64 replication events +--let $count = 64 +while ($count) +{ + INSERT INTO t2 VALUES (DEFAULT); + --dec $count +} + +--connection node_2 +SELECT COUNT(*) = 64 FROM t2; + +SELECT COUNT(*) = @@wsrep_slave_threads + 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user'; +SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE LIKE '%wsrep aborter%'; + + +--eval SET GLOBAL wsrep_slave_threads = $wsrep_slave_threads_orig + +DROP TABLE t1; +DROP TABLE t2; diff --git a/mysql-test/suite/galera/t/galera_var_wsrep_on_off.test b/mysql-test/suite/galera/t/galera_var_wsrep_on_off.test new file mode 100644 index 00000000000..783b78792e6 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_var_wsrep_on_off.test @@ -0,0 +1,32 @@ +# +# Test wsrep_on = OFF. Some events will not be replicated +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +SET SESSION wsrep_on = FALSE; + +# This statement will not be replicated +INSERT INTO t1 VALUES (2); + +--connection node_2 +SELECT COUNT(*) = 1 FROM t1; + +--connection node_1 +SET GLOBAL wsrep_on = TRUE; +INSERT INTO t1 VALUES (3); + +--connection node_2 +SELECT COUNT(*) = 2 FROM t1; + +# Middle insert is not replicated +SELECT COUNT(*) = 0 FROM t1 WHERE f1 = 2; + +# Final insert is replicated +SELECT COUNT(*) = 1 FROM t1 WHERE f1 = 3; + +DROP TABLE t1; + diff --git a/mysql-test/suite/galera/t/galera_wan.cnf b/mysql-test/suite/galera/t/galera_wan.cnf new file mode 100644 index 00000000000..0effd59403b --- /dev/null +++ b/mysql-test/suite/galera/t/galera_wan.cnf @@ -0,0 +1,14 @@ +!include ../galera_4nodes.cnf + +[mysqld.1] +wsrep_provider_options='base_port=@mysqld.1.#galera_port;gcache.size=10M;gmcast.segment=1' + +[mysqld.2] +wsrep_provider_options='base_port=@mysqld.2.#galera_port;gcache.size=10M;gmcast.segment=1' + +[mysqld.3] +wsrep_provider_options='base_port=@mysqld.3.#galera_port;gcache.size=10M;gmcast.segment=2' + +[mysqld.4] +wsrep_provider_options='base_port=@mysqld.4.#galera_port;gcache.size=10M;gmcast.segment=3' + diff --git a/mysql-test/suite/galera/t/galera_wan.test b/mysql-test/suite/galera/t/galera_wan.test new file mode 100644 index 00000000000..a8fd351b168 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_wan.test @@ -0,0 +1,30 @@ +# +# Test WAN replication and the gmcast.segment functionality. +# The galera_wan.cnf file partitions 4 Galera nodes into 3 WAN segments +# +# We can not test any of the actual WAN optimizations from inside MTR and no +# status variables are provided. So we only check that simple replication works. +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; + +--connection node_1 +CREATE TABLE t1 (f1 INTEGER); + +--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3 +--connection node_3 +INSERT INTO t1 VALUES (1); +CALL mtr.add_suppression("There are no nodes in the same segment that will ever be able to become donors, yet there is a suitable donor outside"); + +--connect node_4, 127.0.0.1, root, , test, $NODE_MYPORT_4 +--connection node_4 +SELECT VARIABLE_VALUE LIKE '%gmcast.segment = 3%' FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME = 'wsrep_provider_options'; + +SELECT COUNT(*) = 1 FROM t1; + +DROP TABLE t1; + +CALL mtr.add_suppression("There are no nodes in the same segment that will ever be able to become donors, yet there is a suitable donor outside"); diff --git a/mysql-test/suite/galera/t/galera_wsrep_desync_wsrep_on.test b/mysql-test/suite/galera/t/galera_wsrep_desync_wsrep_on.test new file mode 100644 index 00000000000..3c7988a4924 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_wsrep_desync_wsrep_on.test @@ -0,0 +1,57 @@ +# +# Test the wsrep_desync + wsrep_on method for schema upgrades discussed at +# http://www.slideshare.net/Severalnines/schema-upgrades-codershippresodec2013 , slide 30 +# + +--source include/big_test.inc +--source include/galera_cluster.inc +--source include/have_innodb.inc + +--connection node_1 +CREATE TABLE ten (f1 INTEGER); +INSERT INTO ten VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); + +CREATE TABLE t1 (f1 INTEGER) Engine=InnoDB; + +# Insert some values before the ALTER +INSERT INTO t1 (f1) SELECT 000000 + (10000 * a1.f1) + (1000 * a2.f1) + (100 * a3.f1) + (10 * a4.f1) + a5.f1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5; + +--connection node_2 +SET GLOBAL wsrep_desync = TRUE; +SET SESSION wsrep_on = FALSE; + +ALTER TABLE t1 ADD PRIMARY KEY (f1); + +SET SESSION wsrep_on = TRUE; +SET GLOBAL wsrep_desync = FALSE; + +# Insert even more data after the ALTER has completed +INSERT INTO t1 (f1) SELECT 100000 + (10000 * a1.f1) + (1000 * a2.f1) + (100 * a3.f1) + (10 * a4.f1) + a5.f1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5; + +SELECT COUNT(*) = 200000 FROM t1; +SELECT MAX(f1) = 199999 FROM t1; + +--connection node_1 +SELECT COUNT(*) = 200000 FROM t1; +SELECT MAX(f1) = 199999 FROM t1; + +SET GLOBAL wsrep_desync = TRUE; +SET SESSION wsrep_on = FALSE; + +ALTER TABLE t1 ADD PRIMARY KEY (f1); + +SET SESSION wsrep_on = TRUE; +SET GLOBAL wsrep_desync = FALSE; + +# Insert some conflicting values after the ALTER has been applied on all nodes. + +--connection node_2 +--error ER_DUP_ENTRY +INSERT INTO t1 (f1) VALUES (1); + +--connection node_1 +--error ER_DUP_ENTRY +INSERT INTO t1 (f1) VALUES (100); + +DROP TABLE t1; +DROP TABLE ten; diff --git a/mysql-test/suite/galera/t/galera_wsrep_new_cluster-master.opt b/mysql-test/suite/galera/t/galera_wsrep_new_cluster-master.opt new file mode 100644 index 00000000000..c31150c46af --- /dev/null +++ b/mysql-test/suite/galera/t/galera_wsrep_new_cluster-master.opt @@ -0,0 +1 @@ +--wsrep-new-cluster diff --git a/mysql-test/suite/galera/t/galera_wsrep_new_cluster.test b/mysql-test/suite/galera/t/galera_wsrep_new_cluster.test new file mode 100644 index 00000000000..6ba8ce786c8 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_wsrep_new_cluster.test @@ -0,0 +1,24 @@ +# +# Test the --wsrep-new-cluster option by putting it in the galera_wsrep_new_cluster-master.opt file +# +# In MTR, running two nodes, the result is two separate clusters of size 1 +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_connected'; +SELECT VARIABLE_VALUE = 0 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_index'; +SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready'; +SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state'; +SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; + +--connection node_2 + +SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_connected'; +SELECT VARIABLE_VALUE = 0 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_index'; +SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready'; +SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state'; +SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; diff --git a/mysql-test/suite/galera/t/galera_wsrep_provider_unset_set.test b/mysql-test/suite/galera/t/galera_wsrep_provider_unset_set.test new file mode 100644 index 00000000000..fe4c358bd89 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_wsrep_provider_unset_set.test @@ -0,0 +1,41 @@ +# +# Test that wsrep_provider can be unset and then set back to its original value +# and replication will continue except for any updates made while the value was 'none' +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +--connection node_1 +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); + +--connection node_2 +--let $wsrep_provider_orig = `SELECT @@wsrep_provider` +--let $wsrep_cluster_address_orig = `SELECT @@wsrep_cluster_address` + +SET GLOBAL wsrep_provider='none'; +INSERT INTO t1 VALUES (2); + +--connection node_1 +INSERT INTO t1 VALUES (3); + +--connection node_2 +--disable_query_log +--eval SET GLOBAL wsrep_provider = '$wsrep_provider_orig'; +--eval SET GLOBAL wsrep_cluster_address = '$wsrep_cluster_address_orig'; +--enable_query_log + +--source include/wait_until_connected_again.inc +--source include/galera_wait_ready.inc + +INSERT INTO t1 VALUES (4); + +# Node #2 has all the inserts +SELECT COUNT(*) = 4 FROM t1; + +--connection node_1 +# Node #1 is missing the insert made while Node #2 was not replicated +SELECT COUNT(*) = 3 FROM t1; + +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_zero_length_column.test b/mysql-test/suite/galera/t/galera_zero_length_column.test new file mode 100644 index 00000000000..6ae81a83271 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_zero_length_column.test @@ -0,0 +1,41 @@ +# +# Test columns with size zero. This is known to have tripped other storage engines. +# Keys are not allowed on such columns +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +--connection node_1 +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY , f2 VARCHAR(0)) ENGINE=InnoDB; +CREATE TABLE t2 (f1 VARCHAR(0)) ENGINE=InnoDB; + + +INSERT INTO t1 VALUES (1, NULL); +INSERT INTO t1 VALUES (2, ''); + +INSERT INTO t2 VALUES (NULL); +INSERT INTO t2 VALUES (''); + +--connection node_2 +SELECT COUNT(*) = 2 FROM t1; +SELECT f2 IS NULL FROM t1 WHERE f1 = 1; +SELECT f2 = '' FROM t1 WHERE f1 = 2; + +SELECT COUNT(*) = 2 FROM t2; +SELECT f1 IS NULL FROM t2 WHERE f1 IS NULL; +SELECT f1 = '' FROM t2 WHERE f1 IS NOT NULL; + +UPDATE t1 SET f2 = '' WHERE f1 = 1; +UPDATE t1 SET f2 = NULL WHERE f1 = 2; + +UPDATE t2 SET f1 = '' WHERE f1 IS NULL; + +--connection node_1 +SELECT f2 = '' FROM t1 WHERE f1 = 1; +SELECT f2 IS NULL FROM t1 WHERE f1 = 2; + +SELECT COUNT(*) = 2 FROM t2 WHERE f1 = ''; + +DROP TABLE t1; +DROP TABLE t2; diff --git a/mysql-test/suite/galera/t/lp1276424.test b/mysql-test/suite/galera/t/lp1276424.test new file mode 100644 index 00000000000..a37e950b6a1 --- /dev/null +++ b/mysql-test/suite/galera/t/lp1276424.test @@ -0,0 +1,17 @@ +# +# LP:1276424 Deadlock with insertion of NULL unique ke +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +CREATE TABLE t1 (f1 INT DEFAULT NULL, UNIQUE KEY i1 (f1)) ENGINE=InnoDB; + +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 VALUES (NULL); + +--connection node_2 +SELECT COUNT(*) = 2 FROM t1; +SELECT f1 IS NULL FROM t1; + +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/lp1347768.test b/mysql-test/suite/galera/t/lp1347768.test new file mode 100644 index 00000000000..96d42867c6a --- /dev/null +++ b/mysql-test/suite/galera/t/lp1347768.test @@ -0,0 +1,24 @@ +# +# LP:1347768 Assertion failure in file ha_innodb.cc line 6759 +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +CREATE TABLE `r8kmb_redirect_links` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `old_url` varchar(255) DEFAULT NULL, + `new_url` varchar(255) NOT NULL, + `referer` varchar(150) NOT NULL, + `comment` varchar(255) NOT NULL, + `published` tinyint(4) NOT NULL, + `created_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `modified_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + PRIMARY KEY (`id`), + UNIQUE KEY `idx_link_old` (`old_url`), + KEY `idx_link_modifed` (`modified_date`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +INSERT INTO r8kmb_redirect_links VALUES (550,'http://mysite.com/images/download/ßуñûічýøù_ôþóþòір_þфõÑ.doc','','','',0,'2013-07-15 14:29:42','0000-00-00 00:00:00'); + +DROP TABLE r8kmb_redirect_links; diff --git a/mysql-test/suite/galera/t/lp959512.test b/mysql-test/suite/galera/t/lp959512.test new file mode 100644 index 00000000000..bcc0db24ea7 --- /dev/null +++ b/mysql-test/suite/galera/t/lp959512.test @@ -0,0 +1,26 @@ +# +# LP#959512 IO cache not reset at trx cleanup if write set was empty Edit +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +DROP TABLE IF EXISTS variable; +DROP TABLE IF EXISTS foo; +CREATE TABLE variable ( + name varchar(128) NOT NULL DEFAULT '' COMMENT 'The name of the variable.', + value longblob NOT NULL COMMENT 'The value of the variable.', + PRIMARY KEY (name) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Named variable/value pairs created by Drupal core or any...'; +CREATE TABLE foo (a int); +INSERT INTO variable (name, value) VALUES ('menu_expanded', 'a:0:{}'); +START TRANSACTION; +SELECT 1 AS expression FROM variable variable + WHERE ( (name = 'menu_expanded') ) FOR UPDATE; +UPDATE variable SET value='a:0:{}' WHERE ( (name = 'menu_expanded') ); +COMMIT; +INSERT INTO foo VALUES (1); +UPDATE foo SET a = 2 WHERE a = 1; + +DROP TABLE foo; +DROP TABLE variable; diff --git a/mysql-test/suite/galera/t/mysql-wsrep#33.cnf b/mysql-test/suite/galera/t/mysql-wsrep#33.cnf new file mode 100644 index 00000000000..f1c3d802e4b --- /dev/null +++ b/mysql-test/suite/galera/t/mysql-wsrep#33.cnf @@ -0,0 +1,8 @@ +!include ../galera_2nodes.cnf + +[mysqld.1] +wsrep_provider_options='base_port=@mysqld.1.#galera_port;pc.ignore_sb=true' + +[mysqld.2] +wsrep_provider_options='base_port=@mysqld.2.#galera_port;pc.ignore_sb=true' + diff --git a/mysql-test/suite/galera/t/mysql-wsrep#33.test b/mysql-test/suite/galera/t/mysql-wsrep#33.test new file mode 100644 index 00000000000..acc7c735849 --- /dev/null +++ b/mysql-test/suite/galera/t/mysql-wsrep#33.test @@ -0,0 +1,18 @@ + +--source include/big_test.inc +--source include/galera_cluster.inc +--source include/have_innodb.inc + +--source suite/galera/include/galera_sst_set_mysqldump.inc + +--source suite/galera/include/galera_st_disconnect_slave.inc + +--source suite/galera/include/galera_sst_restore.inc + +--connection node_2 +# We have to manually restore global_log and slow_query_log due to mysql-wsrep#108 +# Otherwise MTR's check_testcases complains + +SET GLOBAL general_log = ON; +SET GLOBAL slow_query_log = ON; + |