| 1 |
############################################################################### |
| 2 |
# This test confirm the correct behavior on savepoint statement when applied |
| 3 |
# on group replication |
| 4 |
# |
| 5 |
# Test: |
| 6 |
# 0. The test requires two serves |
| 7 |
# 1. Create a table to insert data |
| 8 |
# 2. Two transactions that won't block each other due rollback to savepoint, |
| 9 |
# shouldn't cause conflict on group replication |
| 10 |
# 3. Two transactions that won't block each other due rollback to savepoint, |
| 11 |
# shouldn't cause conflict on group replication even without releasing the |
| 12 |
# savepoing |
| 13 |
# 4. Two transactions that block each other shouldn't change the behavior due |
| 14 |
# to use of savepoint |
| 15 |
# |
| 16 |
############################################################################### |
| 17 |
|
| 18 |
--source include/have_debug_sync.inc |
| 19 |
--source include/have_group_replication_plugin.inc |
| 20 |
--source include/group_replication.inc |
| 21 |
|
| 22 |
--let $rpl_connection_name= server1 |
| 23 |
--source include/rpl_connection.inc |
| 24 |
CREATE TABLE t1(a int primary key); |
| 25 |
|
| 26 |
--echo # |
| 27 |
--echo # Don't cause conflict due the rollback |
| 28 |
--echo # |
| 29 |
|
| 30 |
--let $local_server_connection1=server1 |
| 31 |
--let $local_server_connection2=server_1 |
| 32 |
--let $remote_server_connection=server2 |
| 33 |
--let $local_transaction=INSERT INTO t1 VALUES(1); SAVEPOINT A; INSERT INTO t1 values(2); ROLLBACK TO A; RELEASE SAVEPOINT A |
| 34 |
--let $remote_transaction=INSERT INTO t1 VALUES (2) |
| 35 |
# one means I am waiting that happens a conflict (and in this case it shouldn't) |
| 36 |
--let $conflict_test=0 |
| 37 |
--source include/gr_parallel_local_and_remote_transactions.inc |
| 38 |
|
| 39 |
--let $assert_text= 'Table t1 has values 1 and 2' |
| 40 |
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.a = 1 OR t1.a = 2 , count, 1] = 2 |
| 41 |
--source include/assert.inc |
| 42 |
|
| 43 |
--echo # |
| 44 |
--echo # Don't cause conflict due the rollback and the release don't interfere |
| 45 |
--echo # |
| 46 |
|
| 47 |
--let $local_server_connection1=server1 |
| 48 |
--let $local_server_connection2=server_1 |
| 49 |
--let $remote_server_connection=server2 |
| 50 |
--let $local_transaction=INSERT INTO t1 VALUES(3); SAVEPOINT A; INSERT INTO t1 values(4); ROLLBACK TO A |
| 51 |
--let $remote_transaction=INSERT INTO t1 VALUES (4) |
| 52 |
# one means I am waiting that happens a conflict (and in this case it shouldn't) |
| 53 |
--let $conflict_test=0 |
| 54 |
--source include/gr_parallel_local_and_remote_transactions.inc |
| 55 |
|
| 56 |
--let $assert_text= 'Table t1 has values 3 and 4' |
| 57 |
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.a = 3 OR t1.a = 4 , count, 1] = 2 |
| 58 |
--source include/assert.inc |
| 59 |
|
| 60 |
--echo # |
| 61 |
--echo # Using SAVEPOINT don't modify the conflict detection |
| 62 |
--echo # |
| 63 |
|
| 64 |
--let $local_server_connection1=server1 |
| 65 |
--let $local_server_connection2=server_1 |
| 66 |
--let $remote_server_connection=server2 |
| 67 |
--let $local_transaction=INSERT INTO t1 VALUES(5); SAVEPOINT A; INSERT INTO t1 values(6) |
| 68 |
--let $remote_transaction=INSERT INTO t1 VALUES (6); INSERT INTO t1 VALUES(7) |
| 69 |
--let $conflict_test=1 |
| 70 |
--source include/gr_parallel_local_and_remote_transactions.inc |
| 71 |
|
| 72 |
--let $assert_text= 'There are six values in table t1' |
| 73 |
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1, count, 1] = 6 |
| 74 |
--source include/assert.inc |
| 75 |
|
| 76 |
--let $assert_text= 'Table t1 has values 6 and 7' |
| 77 |
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.a = 6 OR t1.a = 7 , count, 1] = 2 |
| 78 |
--source include/assert.inc |
| 79 |
|
| 80 |
--let $assert_text= 'Table t1 do not have value 5' |
| 81 |
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.a = 5, count, 1] = 0 |
| 82 |
--source include/assert.inc |
| 83 |
|
| 84 |
DROP TABLE t1; |
| 85 |
--source include/group_replication_end.inc |