94 lines
3.3 KiB
Plaintext
94 lines
3.3 KiB
Plaintext
################################################################################
|
|
# Verify server behaviour when the same transaction is executed in parallel in
|
|
# two servers.
|
|
#
|
|
# Test:
|
|
# 0. The test requires two servers: M1 and M2.
|
|
# 1. With both members ONLINE, create initial data.
|
|
# 2. Executing the same update transaction on both server (almost) in parallel,
|
|
# one will be committed, the other will be aborted.
|
|
# 3. Validate servers state is equal.
|
|
# 4. Clean up.
|
|
################################################################################
|
|
--let $group_replication_group_name= 8a94f357-aab4-11df-86ab-c80aa9429999
|
|
--source include/have_group_replication_plugin.inc
|
|
--source include/group_replication.inc
|
|
|
|
--connection server1
|
|
--echo ############################################################
|
|
--echo # 1. Execute some transactions on server1 and wait for group
|
|
--echo # to be synchronized.
|
|
CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
|
|
INSERT INTO t1 VALUES (0);
|
|
|
|
--let $sync_slave_connection= server2
|
|
--source include/sync_slave_sql_with_master.inc
|
|
|
|
--echo ############################################################
|
|
--echo # 2. Executing the same transaction on both server (almost)
|
|
--echo # in parallel, one will be committed, the other will be
|
|
--echo # aborted.
|
|
--disable_query_log
|
|
--disable_result_log
|
|
--let $include_silent= 1
|
|
|
|
--let $value_old= 0
|
|
--let $value_new= 1
|
|
--let $transactions= 50
|
|
while ($transactions > 0)
|
|
{
|
|
--let $query= UPDATE t1 SET c1=$value_new WHERE c1=$value_old
|
|
|
|
--connection server1
|
|
--send_eval $query
|
|
--connection server2
|
|
--send_eval $query
|
|
|
|
--connection server1
|
|
--error 0, ER_TRANSACTION_ROLLBACK_DURING_COMMIT, ER_ERROR_DURING_COMMIT, ER_LOCK_DEADLOCK, ER_LOCK_WAIT_TIMEOUT
|
|
--reap
|
|
--connection server2
|
|
--error 0, ER_TRANSACTION_ROLLBACK_DURING_COMMIT, ER_ERROR_DURING_COMMIT, ER_LOCK_DEADLOCK, ER_LOCK_WAIT_TIMEOUT
|
|
--reap
|
|
|
|
# Sync both servers to ensure that next transaction does not fail
|
|
# with mismatch where clause.
|
|
--let $sync_slave_connection= server1
|
|
--source include/sync_slave_sql_with_master.inc
|
|
--let $sync_slave_connection= server2
|
|
--source include/sync_slave_sql_with_master.inc
|
|
|
|
--dec $transactions
|
|
--inc $value_old
|
|
--inc $value_new
|
|
}
|
|
--enable_query_log
|
|
--enable_result_log
|
|
--let $include_silent= 0
|
|
|
|
--echo ############################################################
|
|
--echo # 3. Validate servers state is equal.
|
|
--let $diff_tables= server1:t1, server2:t1
|
|
--source include/diff_tables.inc
|
|
|
|
--connection server1
|
|
--let $assert_text= 'There is only one row in table t1 on server 1'
|
|
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1, count, 1] = 1
|
|
--source include/assert.inc
|
|
--let $assert_text= 'There is a value 50 in table t1 on server 1'
|
|
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 50, count, 1] = 1
|
|
--source include/assert.inc
|
|
|
|
--connection server2
|
|
--let $assert_text= 'There is only one row in table t1 on server 2'
|
|
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1, count, 1] = 1
|
|
--source include/assert.inc
|
|
--let $assert_text= 'There is a value 50 in table t1 on server 2'
|
|
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 50, count, 1] = 1
|
|
--source include/assert.inc
|
|
|
|
--echo ############################################################
|
|
--echo # 4. Clean up.
|
|
DROP TABLE t1;
|
|
--source include/group_replication_end.inc
|