| 1 |
################################################################################ |
| 2 |
# Verify server behaviour when the same transaction is executed in parallel |
| 3 |
# in two servers. |
| 4 |
# |
| 5 |
# Test: |
| 6 |
# 0. The test requires two servers: M1 and M2. |
| 7 |
# 1. With both the members ONLINE. Create a 20 tables on M1. |
| 8 |
# 2. Executing the same insert transaction on both server (almost) in parallel, |
| 9 |
# one will be committed, the other will be aborted |
| 10 |
# 3. Validate servers state is equal by checking gtid_executed and table data. |
| 11 |
# 4. Clean up. |
| 12 |
################################################################################ |
| 13 |
--source include/have_group_replication_plugin.inc |
| 14 |
--source include/group_replication.inc |
| 15 |
--let $transactions= 1000 |
| 16 |
--let $i= 0 |
| 17 |
--let $tables= 20 |
| 18 |
|
| 19 |
--echo |
| 20 |
--echo ############################################################ |
| 21 |
--echo # 1. Create 20 tables on server1 and wait for group to be |
| 22 |
--echo # synchronized. |
| 23 |
while($i < $tables) |
| 24 |
{ |
| 25 |
--eval CREATE TABLE t$i (c1 INT NOT NULL PRIMARY KEY) |
| 26 |
--inc $i |
| 27 |
} |
| 28 |
--source include/rpl_sync.inc |
| 29 |
|
| 30 |
--echo |
| 31 |
--echo ############################################################ |
| 32 |
--echo # 2. Executing the same transaction on both server (almost) |
| 33 |
--echo # in parallel, one will be committed, the other will be |
| 34 |
--echo # aborted. |
| 35 |
--let $t= 0 |
| 36 |
--disable_query_log |
| 37 |
while($t < $transactions) |
| 38 |
{ |
| 39 |
--inc $t |
| 40 |
--let $index= `select MOD($t, $tables)` |
| 41 |
--connection server1 |
| 42 |
--send_eval INSERT INTO t$index VALUES ($t) |
| 43 |
|
| 44 |
--connection server2 |
| 45 |
--send_eval INSERT INTO t$index VALUES ($t) |
| 46 |
|
| 47 |
--connection server1 |
| 48 |
--error 0, ER_TRANSACTION_ROLLBACK_DURING_COMMIT, ER_ERROR_DURING_COMMIT, ER_DUP_ENTRY, ER_LOCK_DEADLOCK, ER_LOCK_WAIT_TIMEOUT |
| 49 |
--reap |
| 50 |
|
| 51 |
--connection server2 |
| 52 |
--error 0, ER_TRANSACTION_ROLLBACK_DURING_COMMIT, ER_ERROR_DURING_COMMIT, ER_DUP_ENTRY, ER_LOCK_DEADLOCK, ER_LOCK_WAIT_TIMEOUT |
| 53 |
--reap |
| 54 |
} |
| 55 |
--enable_query_log |
| 56 |
|
| 57 |
# Sync server1, server2 |
| 58 |
--let $rpl_connection_name= server1 |
| 59 |
--source include/rpl_connection.inc |
| 60 |
--let $sync_slave_connection= server2 |
| 61 |
--source include/sync_slave_sql_with_master.inc |
| 62 |
|
| 63 |
--let $rpl_connection_name= server2 |
| 64 |
--source include/rpl_connection.inc |
| 65 |
--let $sync_slave_connection= server1 |
| 66 |
--source include/sync_slave_sql_with_master.inc |
| 67 |
|
| 68 |
--echo ############################################################ |
| 69 |
--echo # 3. Validate servers state is equal. |
| 70 |
|
| 71 |
--let $rpl_connection_name= server1 |
| 72 |
--source include/rpl_connection.inc |
| 73 |
--let $server1_gtid_executed= `SELECT @@GLOBAL.GTID_EXECUTED` |
| 74 |
|
| 75 |
--let $rpl_connection_name= server2 |
| 76 |
--source include/rpl_connection.inc |
| 77 |
--let $server2_gtid_executed= `SELECT @@GLOBAL.GTID_EXECUTED` |
| 78 |
|
| 79 |
--let $assert_text= server1 GTID_EXECUTED must be equal to server2 GTID_EXECUTED |
| 80 |
--let $assert_cond= "$server1_gtid_executed" = "$server2_gtid_executed" |
| 81 |
--source include/assert.inc |
| 82 |
|
| 83 |
# Check that all tables has same data in server1, server2 |
| 84 |
--let $i=0 |
| 85 |
while($i < $tables) |
| 86 |
{ |
| 87 |
--let $diff_tables= server1:t$i, server2:t$i |
| 88 |
--source include/diff_tables.inc |
| 89 |
--inc $i |
| 90 |
} |
| 91 |
|
| 92 |
--echo |
| 93 |
--echo ############################################################ |
| 94 |
--echo # 4. Clean up. |
| 95 |
--let $i= 0 |
| 96 |
while($i < $tables) |
| 97 |
{ |
| 98 |
--eval DROP TABLE IF EXISTS t$i |
| 99 |
--inc $i |
| 100 |
} |
| 101 |
--source include/group_replication_end.inc |