| 1 |
################################################################################ |
| 2 |
# Test case to verify that concurrent transactions with intersecting |
| 3 |
# write set, on table with multiple primary. |
| 4 |
# |
| 5 |
# Scenario 8.2: on WL#6834 page |
| 6 |
# |
| 7 |
# T1: WS={t1.(a,b)=(1,2)} |
| 8 |
# {t1.(a,b)=(3,2)} |
| 9 |
# |
| 10 |
# T2: WS={t1.(a,b)=(1,2)} |
| 11 |
# {t1.(a,b)=(4,2)} |
| 12 |
# |
| 13 |
# Outcome: T1 must abort, T2 must commit. |
| 14 |
# |
| 15 |
# Full details on WL#6834 QA notes. |
| 16 |
# |
| 17 |
# Test: |
| 18 |
# 0. The test requires two servers: M1 and M2. |
| 19 |
# 1. With both the members ONLINE. Create a table on M1. |
| 20 |
# 2. Set a DEBUG sync before broadcast message to group on connection M1. |
| 21 |
# Commit a transaction that will be block before broadcast. |
| 22 |
# 3. Wait until connection reaches DEBUG sync point. |
| 23 |
# 4. Execute a transaction on M2, that will reach first certification, |
| 24 |
# since M1 is blocked before broadcast. |
| 25 |
# 5. Signal the waiting thread on M1 to resume. |
| 26 |
# 6. It will end up in an error stating that it was aborted, since |
| 27 |
# transactions are conflicting and M2 was ordered first. |
| 28 |
# 7. Assert that number of certified transactions are the expected one. |
| 29 |
# |
| 30 |
# Checking the positive case in which there is no conflict. |
| 31 |
# 8. Set a DEBUG sync before broadcast message to group on connection M1. |
| 32 |
# Commit a transaction that will be block before broadcast. |
| 33 |
# 9. Wait until connection reaches DEBUG sync point. |
| 34 |
# 10. Execute a transaction on M2, that will reach first certification, |
| 35 |
# since M1 is blocked before broadcast. |
| 36 |
# 11. Signal the waiting thread on M1 to resume. |
| 37 |
# 12. It will execute without error as the conflicting transactions have been |
| 38 |
# removed. |
| 39 |
# 13. Assert that number of certified transactions are the expected one. |
| 40 |
# 14. Clean up. |
| 41 |
################################################################################ |
| 42 |
|
| 43 |
--source include/have_debug_sync.inc |
| 44 |
--source include/have_group_replication_plugin.inc |
| 45 |
--source include/group_replication.inc |
| 46 |
|
| 47 |
--echo |
| 48 |
--echo ############################################################ |
| 49 |
--echo # 1. Create a table on server1. |
| 50 |
--let $rpl_connection_name= server1 |
| 51 |
--source include/rpl_connection.inc |
| 52 |
CREATE TABLE t1(a INT, b INT, PRIMARY KEY(a, b)); |
| 53 |
INSERT INTO t1 VALUE(1, 2); |
| 54 |
--source include/rpl_sync.inc |
| 55 |
|
| 56 |
--echo |
| 57 |
--echo ############################################################ |
| 58 |
--echo # 2. Set a debug sync before broadcast message to group on |
| 59 |
--echo # connection server_1. |
| 60 |
--echo # Commit a transaction that will be block before broadcast. |
| 61 |
--let $rpl_connection_name= server_1 |
| 62 |
--source include/rpl_connection.inc |
| 63 |
SET @debug_save= @@GLOBAL.DEBUG; |
| 64 |
SET @@GLOBAL.DEBUG='d,group_replication_before_message_broadcast'; |
| 65 |
BEGIN; |
| 66 |
UPDATE t1 SET a=3 AND b=5 WHERE a=1; |
| 67 |
--send COMMIT |
| 68 |
|
| 69 |
--echo |
| 70 |
--echo ############################################################ |
| 71 |
--echo # 3. Wait until server_1 connection reaches the |
| 72 |
--echo # group_replication_before_message_broadcast debug sync point. |
| 73 |
--let $rpl_connection_name= server1 |
| 74 |
--source include/rpl_connection.inc |
| 75 |
--let $wait_condition=SELECT COUNT(*)=1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE State = 'debug sync point: now' |
| 76 |
--source include/wait_condition.inc |
| 77 |
|
| 78 |
--echo |
| 79 |
--echo ############################################################ |
| 80 |
--echo # 4. Execute a transaction on server2, that will reach first |
| 81 |
--echo # certification, since server_1 is blocked before broadcast. |
| 82 |
--let $rpl_connection_name= server2 |
| 83 |
--source include/rpl_connection.inc |
| 84 |
UPDATE t1 SET a=4 AND b=5 WHERE b=2; |
| 85 |
|
| 86 |
--echo |
| 87 |
--echo ############################################################ |
| 88 |
--echo # 5. Signal the waiting thread on server_1 to resume. |
| 89 |
--let $rpl_connection_name= server1 |
| 90 |
--source include/rpl_connection.inc |
| 91 |
SET DEBUG_SYNC='now SIGNAL waiting'; |
| 92 |
SET @@GLOBAL.DEBUG= @debug_save; |
| 93 |
|
| 94 |
--echo |
| 95 |
--echo ############################################################ |
| 96 |
--echo # 6. It will end up in an error stating that it was aborted, |
| 97 |
--echo # since transactions are conflicting and server2 was |
| 98 |
--echo # ordered first. |
| 99 |
--let $rpl_connection_name= server2 |
| 100 |
--source include/rpl_connection.inc |
| 101 |
--let $sync_slave_connection= server1 |
| 102 |
--source include/sync_slave_sql_with_master.inc |
| 103 |
|
| 104 |
--let $rpl_connection_name= server_1 |
| 105 |
--source include/rpl_connection.inc |
| 106 |
--error ER_TRANSACTION_ROLLBACK_DURING_COMMIT |
| 107 |
--reap |
| 108 |
|
| 109 |
--echo |
| 110 |
--echo ############################################################ |
| 111 |
--echo # 7. Assert that number of certified transactions are the |
| 112 |
--echo # expected ones. |
| 113 |
--let $rpl_connection_name= server1 |
| 114 |
--source include/rpl_connection.inc |
| 115 |
|
| 116 |
--let $certified_transactions= query_get_value(SELECT Count_Transactions_Checked from performance_schema.replication_group_member_stats where member_id in (SELECT @@server_uuid), Count_Transactions_Checked, 1) |
| 117 |
--let $assert_text= The value of Count_Transactions_Checked should be 4 after starting group replication |
| 118 |
--let $assert_cond= "$certified_transactions" = 4 |
| 119 |
--source include/assert.inc |
| 120 |
|
| 121 |
--let $negatively_certified= query_get_value(SELECT Count_Conflicts_Detected from performance_schema.replication_group_member_stats where member_id in (SELECT @@server_uuid), Count_Conflicts_Detected, 1) |
| 122 |
--let $assert_text= The value of Count_Conflicts_Detected should be 1 after starting group replication |
| 123 |
--let $assert_cond= "$negatively_certified" = 1 |
| 124 |
--source include/assert.inc |
| 125 |
|
| 126 |
--echo |
| 127 |
--echo ############################################################ |
| 128 |
--echo # Checking the positive case in which there is no conflict. |
| 129 |
--echo ############################################################ |
| 130 |
--echo |
| 131 |
--echo ############################################################ |
| 132 |
--echo # 1. Set a debug sync before broadcast message to group on |
| 133 |
--echo # connection server_1. |
| 134 |
--echo # Commit a transaction that will be block before broadcast. |
| 135 |
--let $rpl_connection_name= server_1 |
| 136 |
--source include/rpl_connection.inc |
| 137 |
SET @@GLOBAL.DEBUG='d,group_replication_before_message_broadcast'; |
| 138 |
BEGIN; |
| 139 |
INSERT INTO t1 VALUE(10, 11); |
| 140 |
--send COMMIT |
| 141 |
|
| 142 |
--echo |
| 143 |
--echo ############################################################ |
| 144 |
--echo # 2. Wait until server_1 connection reaches the |
| 145 |
--echo # group_replication_before_message_broadcast debug sync point. |
| 146 |
--let $rpl_connection_name= server1 |
| 147 |
--source include/rpl_connection.inc |
| 148 |
--let $wait_condition=SELECT COUNT(*)=1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE State = 'debug sync point: now' |
| 149 |
--source include/wait_condition.inc |
| 150 |
|
| 151 |
--echo |
| 152 |
--echo ############################################################ |
| 153 |
--echo # 3. Execute a transaction on server2, that will reach first |
| 154 |
--echo # certification, since server_1 is blocked before broadcast. |
| 155 |
--let $rpl_connection_name= server2 |
| 156 |
--source include/rpl_connection.inc |
| 157 |
INSERT INTO t1 VALUE(12, 13); |
| 158 |
--let $sync_slave_connection= server1 |
| 159 |
--source include/sync_slave_sql_with_master.inc |
| 160 |
|
| 161 |
--echo |
| 162 |
--echo ############################################################ |
| 163 |
--echo # 4. Signal the waiting thread on server_1 to resume. |
| 164 |
--let $rpl_connection_name= server1 |
| 165 |
--source include/rpl_connection.inc |
| 166 |
SET DEBUG_SYNC='now SIGNAL waiting'; |
| 167 |
SET @@GLOBAL.DEBUG= @debug_save; |
| 168 |
|
| 169 |
--echo |
| 170 |
--echo ######################################################################## |
| 171 |
--echo # 5. It will execute without error as the conflicting transactions have |
| 172 |
--echo # been removed. |
| 173 |
--let $rpl_connection_name= server_1 |
| 174 |
--source include/rpl_connection.inc |
| 175 |
--reap |
| 176 |
|
| 177 |
--source include/rpl_sync.inc |
| 178 |
--echo |
| 179 |
--echo ############################################################ |
| 180 |
--echo # 6. Assert that number of certified transactions are the |
| 181 |
--echo # expected ones. |
| 182 |
--let $rpl_connection_name= server1 |
| 183 |
--source include/rpl_connection.inc |
| 184 |
|
| 185 |
--let $assert_text= Table t1 will contain row after the above execution |
| 186 |
--let $assert_cond= "[SELECT COUNT(*) AS count FROM t1 WHERE t1.a = 0 AND t1.b = 2, count, 1]" = "1" |
| 187 |
--source include/assert.inc |
| 188 |
|
| 189 |
--let $assert_text= Table t1 will contain row after the above execution |
| 190 |
--let $assert_cond= "[SELECT COUNT(*) AS count FROM t1 WHERE t1.a = 10 AND t1.b = 11, count, 1]" = "1" |
| 191 |
--source include/assert.inc |
| 192 |
|
| 193 |
--let $assert_text= Table t1 will contain row after the above execution |
| 194 |
--let $assert_cond= "[SELECT COUNT(*) AS count FROM t1 WHERE t1.a = 12 AND t1.b = 13, count, 1]" = "1" |
| 195 |
--source include/assert.inc |
| 196 |
|
| 197 |
--let $assert_text= Table t1 will contain 3 rows after the above execution |
| 198 |
--let $assert_cond= "[SELECT COUNT(*) FROM t1]" = "3" |
| 199 |
--source include/assert.inc |
| 200 |
|
| 201 |
--let $certified_transactions= query_get_value(SELECT Count_Transactions_Checked from performance_schema.replication_group_member_stats where member_id in (SELECT @@server_uuid), Count_Transactions_Checked, 1) |
| 202 |
--let $assert_text= The value of Count_Transactions_Checked should be 6 after starting group replication |
| 203 |
--let $assert_cond= "$certified_transactions" = 6 |
| 204 |
--source include/assert.inc |
| 205 |
|
| 206 |
--let $negatively_certified= query_get_value(SELECT Count_Conflicts_Detected from performance_schema.replication_group_member_stats where member_id in (SELECT @@server_uuid), Count_Conflicts_Detected, 1) |
| 207 |
--let $assert_text= The value of Count_Conflicts_Detected should be 1 after starting group replication |
| 208 |
--let $assert_cond= "$negatively_certified" = 1 |
| 209 |
--source include/assert.inc |
| 210 |
|
| 211 |
--echo |
| 212 |
--echo ############################################################ |
| 213 |
--echo # Clean up. |
| 214 |
DROP TABLE t1; |
| 215 |
|
| 216 |
--source include/group_replication_end.inc |