| 1 |
############################################################################### |
| 2 |
# |
| 3 |
# This test validate that if we have two sessions and one set gtid_next to the |
| 4 |
# next automatic gtid, if both session execute a transaction in parallel one |
| 5 |
# of the transactions will rollback. |
| 6 |
# |
| 7 |
# Test: |
| 8 |
# 0. Test requires two servers. |
| 9 |
# 1. Establish another connection to server, to execute transactions in |
| 10 |
# parallel. |
| 11 |
# 2. Create a table and set a manual gtid_next equal to next automatic gtid. |
| 12 |
# Start a transaction. |
| 13 |
# 3. Using the other connection execute a transaction. |
| 14 |
# 4. Connect to first session and commit pending transaction. Server will |
| 15 |
# rollback it due to already used gtid. |
| 16 |
# 5. Clean up. |
| 17 |
# |
| 18 |
############################################################################### |
| 19 |
|
| 20 |
--let $group_replication_group_name= c3b5927f-2a51-11e7-94b3-0010e0734796 |
| 21 |
--source include/have_group_replication_plugin.inc |
| 22 |
--source include/group_replication.inc |
| 23 |
|
| 24 |
--let $rpl_connection_name= server2 |
| 25 |
--source include/rpl_connection.inc |
| 26 |
set sql_log_bin=0; |
| 27 |
call mtr.add_suppression("The requested GTID .* was already used, the transaction will rollback"); |
| 28 |
set sql_log_bin=1; |
| 29 |
|
| 30 |
--echo |
| 31 |
--echo ############################################################# |
| 32 |
--echo # 1. Establish another connection to server, to execute |
| 33 |
--echo # transactions in parallel. |
| 34 |
|
| 35 |
--let $rpl_connection_name= server1 |
| 36 |
--source include/rpl_connection.inc |
| 37 |
|
| 38 |
set sql_log_bin=0; |
| 39 |
call mtr.add_suppression("The requested GTID .* was already used, the transaction will rollback"); |
| 40 |
set sql_log_bin=1; |
| 41 |
|
| 42 |
CREATE TABLE t1(a INT PRIMARY KEY); |
| 43 |
--source include/rpl_sync.inc |
| 44 |
|
| 45 |
--echo |
| 46 |
--echo ############################################################# |
| 47 |
--echo # 2. Create a table and set a manual gtid_next equal to next |
| 48 |
--echo # automatic gtid. Start a transaction. |
| 49 |
|
| 50 |
--let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "c3b5927f-2a51-11e7-94b3-0010e0734796:1-3" |
| 51 |
--let $assert_text= GTID_EXECUTED should contain three GTIDs. |
| 52 |
--source include/assert.inc |
| 53 |
|
| 54 |
set GTID_NEXT='c3b5927f-2a51-11e7-94b3-0010e0734796:4'; |
| 55 |
BEGIN; |
| 56 |
INSERT INTO t1 VALUES (1); |
| 57 |
|
| 58 |
--echo |
| 59 |
--echo ############################################################# |
| 60 |
--echo # 3. Using the other connection execute a transaction. |
| 61 |
|
| 62 |
--let $rpl_connection_name= server_1 |
| 63 |
--source include/rpl_connection.inc |
| 64 |
INSERT INTO t1 VALUES (2); |
| 65 |
|
| 66 |
--echo |
| 67 |
--echo ############################################################# |
| 68 |
--echo # 4. Connect to first session and commit pending transaction. |
| 69 |
--echo # Server will rollback it due to already used gtid. |
| 70 |
|
| 71 |
--let $rpl_connection_name= server1 |
| 72 |
--source include/rpl_connection.inc |
| 73 |
|
| 74 |
--let $wait_condition= SELECT @@GLOBAL.GTID_EXECUTED = 'c3b5927f-2a51-11e7-94b3-0010e0734796:1-4' |
| 75 |
--source include/wait_condition.inc |
| 76 |
|
| 77 |
--error ER_TRANSACTION_ROLLBACK_DURING_COMMIT |
| 78 |
COMMIT; |
| 79 |
set GTID_NEXT='automatic'; |
| 80 |
|
| 81 |
--let $assert_file= $MYSQLTEST_VARDIR/tmp/gr_gtid_next_conflict.1.err |
| 82 |
--let $assert_count= 1 |
| 83 |
--let $assert_select= .* was already used, the transaction will rollback |
| 84 |
--let $assert_text= The GR plug-in reported an error stating that a transaction will rollback |
| 85 |
--source include/assert_grep.inc |
| 86 |
|
| 87 |
--echo |
| 88 |
--echo ############################################################# |
| 89 |
--echo # 5. Clean up. |
| 90 |
DROP TABLE t1; |
| 91 |
--source include/group_replication_end.inc |