1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
|
################################################################################
# Test case to verify that concurrent transactions with intersecting
# write set, on json array with unique keys, do conflict.
#
# Test:
# 0. The test requires two servers: M1 and M2.
# 1. With both members ONLINE. Create a table on M1.
# 2. Set a debug sync before broadcast message to group on M1. Commit a
# transaction that will be blocked before broadcast.
# 3. Wait until M1 reaches the debug sync point.
# 4. Execute a transaction on M2, that will reach first certification, since M1
# is blocked before broadcast.
# 5. Signal the waiting thread on M1 to resume.
# 6. It will end up in an error stating that it was aborted, since transactions
# are conflicting and M2 was ordered first.
# 7. Assert that number of certified transactions are the expected ones.
#
# Checking the positive case in which there is no conflict:
# 8. Set a debug sync before broadcast message to group on M1. Commit a
# transaction that will be block before broadcast.
# 9. Wait until M1 reaches the debug sync point.
# 10. Execute a transaction on M2, that will reach first certification, since M1
# is blocked before broadcast.
# 11. Signal the waiting thread on M1 to resume.
# 12. It will execute without error as the conflicting transactions have been
# removed.
# 13. Assert that number of certified transactions are the expected ones.
# 14. Clean up.
################################################################################
--source include/have_debug_sync.inc
--source include/have_group_replication_plugin.inc
--source include/group_replication.inc
--echo
--echo ############################################################
--echo # Create a table on server1.
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY, data JSON,
UNIQUE KEY zips((CAST(CAST(data AS JSON) AS UNSIGNED ARRAY))));
INSERT INTO t1(c1,data) VALUES (1,'[0,1,2]');
INSERT INTO t1(c1,data) VALUES (2,'[100,101]');
--source include/rpl_sync.inc
--echo
--echo ############################################################
--echo # Checking the conflict case.
--let $local_server_connection1=server1
--let $local_server_connection2=server_1
--let $remote_server_connection=server2
--let $local_transaction= UPDATE t1 SET data = '[6,7,8]' WHERE JSON_CONTAINS(CAST(data AS JSON),'1')
--let $remote_transaction=UPDATE t1 SET data = '[3,4,5]' WHERE JSON_CONTAINS(CAST(data AS JSON),'1')
--let $conflict_test=1
--source include/gr_parallel_local_and_remote_transactions.inc
--echo
--echo ############################################################
--echo # Checking the conflict case.
--let $local_server_connection1=server1
--let $local_server_connection2=server_1
--let $remote_server_connection=server2
--let $local_transaction= INSERT INTO t1(c1,data) VALUES (4,'[13,14]');
--let $remote_transaction=INSERT INTO t1(c1,data) VALUES (3,'[12,13]');
--let $conflict_test=1
--source include/gr_parallel_local_and_remote_transactions.inc
--echo
--echo ############################################################
--echo # Checking the positive case in which there is no conflict.
--let $local_server_connection1=server1
--let $local_server_connection2=server_1
--let $remote_server_connection=server2
--let $local_transaction= UPDATE t1 SET data = '[10,11]' WHERE JSON_CONTAINS(CAST(data AS JSON),'100')
--let $remote_transaction=UPDATE t1 SET data = '[9]' WHERE JSON_CONTAINS(CAST(data AS JSON),'3')
--let $conflict_test=0
--source include/gr_parallel_local_and_remote_transactions.inc
--echo
--echo ############################################################
--echo # Checking the positive case in which there is no conflict.
--let $local_server_connection1=server1
--let $local_server_connection2=server_1
--let $remote_server_connection=server2
--let $local_transaction= INSERT INTO t1(c1,data) VALUES (4,NULL);
--let $remote_transaction=INSERT INTO t1(c1,data) VALUES (5,NULL);
--let $conflict_test=0
--source include/gr_parallel_local_and_remote_transactions.inc
--echo
--echo ############################################################
--echo # Check the data sanity
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
--let $assert_text= Table t1 will contain 2 rows after the above execution
--let $assert_cond= "[SELECT COUNT(*) FROM t1]" = "5"
--source include/assert.inc
--let $assert_text= Table t1 will contain row after the above execution
--let $assert_cond= "[SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 1, count, 1]" = "1"
--source include/assert.inc
--let $assert_text= Table t1 will contain row after the above execution
--let $assert_cond= "[SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 2, count, 1]" = "1"
--source include/assert.inc
--let $assert_text= Table t1 will contain row after the above execution
--let $assert_cond= "[SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 3, count, 1]" = "1"
--source include/assert.inc
--let $assert_text= Table t1 will contain row after the above execution
--let $assert_cond= "[SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 4, count, 1]" = "1"
--source include/assert.inc
--let $assert_text= Table t1 will contain row after the above execution
--let $assert_cond= "[SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 5, count, 1]" = "1"
--source include/assert.inc
SELECT * FROM t1;
--let $diff_tables=server1:t1, server2:t1
--source include/diff_tables.inc
--echo
--echo ############################################################
--echo # Clean up.
DROP TABLE t1;
--source include/group_replication_end.inc
|