| 1 |
# |
| 2 |
# MDEV-26707: SR transaction rolls back locally, but not in cluster |
| 3 |
# |
| 4 |
# This test excercises the following scenario: |
| 5 |
# Initially we have a three node cluster where node 2 has an active |
| 6 |
# SR transaction that has replicated one fragment. |
| 7 |
# Node 3 disconnects from the cluster, followed by disconnect of node 2. |
| 8 |
# Node 2 attempts to COMMIT its transaction, but fails because node 2 is |
| 9 |
# non-primary. This failure causes the transaction to rolled back locally |
| 10 |
# (node 2 can't communicate with the cluster at this point, so rollback |
| 11 |
# fragment cannot be sent successfully) |
| 12 |
# Node 3 joins back creating non-primary view (node 1, node 3). |
| 13 |
# Then node 2 joins back creating primary view (node 1, node 1, node 3). |
| 14 |
# If bug is present, we have that node 2 has rolled back locally, while |
| 15 |
# the same transaction is still active nodes 1 and 3, leaving entries |
| 16 |
# in their wsrep_streaming_log tables. |
| 17 |
# |
| 18 |
|
| 19 |
--source include/galera_cluster.inc |
| 20 |
--source include/have_debug_sync.inc |
| 21 |
|
| 22 |
--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1 |
| 23 |
--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2 |
| 24 |
--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3 |
| 25 |
--connect node_3a, 127.0.0.1, root, , test, $NODE_MYPORT_3 |
| 26 |
|
| 27 |
# Save original auto_increment_offset values. |
| 28 |
--let $node_1=node_1 |
| 29 |
--let $node_2=node_2 |
| 30 |
--let $node_3=node_3 |
| 31 |
--source ../galera/include/auto_increment_offset_save.inc |
| 32 |
|
| 33 |
--connection node_1 |
| 34 |
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY); |
| 35 |
|
| 36 |
--connection node_2 |
| 37 |
SET SESSION wsrep_trx_fragment_size=1; |
| 38 |
BEGIN; |
| 39 |
INSERT INTO t1 VALUES (21); |
| 40 |
|
| 41 |
--connection node_1 |
| 42 |
SELECT COUNT(*) AS EXPECT_1 FROM mysql.wsrep_streaming_log; |
| 43 |
|
| 44 |
--connection node_2 |
| 45 |
SELECT COUNT(*) AS EXPECT_1 FROM mysql.wsrep_streaming_log; |
| 46 |
|
| 47 |
--connection node_3 |
| 48 |
SELECT COUNT(*) AS EXPECT_1 FROM mysql.wsrep_streaming_log; |
| 49 |
|
| 50 |
# |
| 51 |
# Disconnect node 3 from cluster |
| 52 |
# |
| 53 |
--connection node_3a |
| 54 |
SET GLOBAL wsrep_provider_options = 'gmcast.isolate = 1'; |
| 55 |
SET SESSION wsrep_sync_wait = 0; |
| 56 |
--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' |
| 57 |
--source include/wait_condition.inc |
| 58 |
SET SESSION wsrep_sync_wait = DEFAULT; |
| 59 |
|
| 60 |
--connection node_1a |
| 61 |
SET SESSION wsrep_sync_wait = 0; |
| 62 |
--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' |
| 63 |
--source include/wait_condition.inc |
| 64 |
SET SESSION wsrep_sync_wait = DEFAULT; |
| 65 |
|
| 66 |
--connection node_2a |
| 67 |
SET SESSION wsrep_sync_wait = 0; |
| 68 |
--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' |
| 69 |
--source include/wait_condition.inc |
| 70 |
SET SESSION wsrep_sync_wait = DEFAULT; |
| 71 |
|
| 72 |
# |
| 73 |
# Issue commit block COMMIT before certification on node 2 |
| 74 |
# |
| 75 |
--connection node_2 |
| 76 |
SET DEBUG_SYNC = 'wsrep_before_certification SIGNAL before_cert WAIT_FOR continue'; |
| 77 |
--send COMMIT |
| 78 |
|
| 79 |
--connection node_2a |
| 80 |
SET DEBUG_SYNC = 'now WAIT_FOR before_cert'; |
| 81 |
|
| 82 |
# |
| 83 |
# Disconnect node 2 |
| 84 |
# |
| 85 |
SET GLOBAL wsrep_provider_options = 'gmcast.isolate = 1'; |
| 86 |
SET SESSION wsrep_sync_wait = 0; |
| 87 |
--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' |
| 88 |
--source include/wait_condition.inc |
| 89 |
SET SESSION wsrep_sync_wait = DEFAULT; |
| 90 |
|
| 91 |
|
| 92 |
# |
| 93 |
# Unblock COMMIT and expect it to fail |
| 94 |
# |
| 95 |
SET DEBUG_SYNC = 'now SIGNAL continue'; |
| 96 |
|
| 97 |
--connection node_2 |
| 98 |
--error ER_ERROR_DURING_COMMIT |
| 99 |
--reap |
| 100 |
|
| 101 |
--connection node_2a |
| 102 |
SET DEBUG_SYNC = 'RESET'; |
| 103 |
|
| 104 |
--connection node_1a |
| 105 |
SET SESSION wsrep_sync_wait = 0; |
| 106 |
--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' |
| 107 |
--source include/wait_condition.inc |
| 108 |
SET SESSION wsrep_sync_wait = DEFAULT; |
| 109 |
|
| 110 |
|
| 111 |
# |
| 112 |
# Reconnect node 3 |
| 113 |
# |
| 114 |
--connection node_3a |
| 115 |
SET GLOBAL wsrep_provider_options = 'gmcast.isolate = 0'; |
| 116 |
SET SESSION wsrep_sync_wait = 0; |
| 117 |
--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' |
| 118 |
--source include/wait_condition.inc |
| 119 |
SELECT COUNT(*) AS EXPECT_1 FROM mysql.wsrep_streaming_log; |
| 120 |
SET SESSION wsrep_sync_wait = DEFAULT; |
| 121 |
|
| 122 |
--connection node_1a |
| 123 |
SET SESSION wsrep_sync_wait = 0; |
| 124 |
--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' |
| 125 |
--source include/wait_condition.inc |
| 126 |
SELECT COUNT(*) AS EXPECT_1 FROM mysql.wsrep_streaming_log; |
| 127 |
SET SESSION wsrep_sync_wait = DEFAULT; |
| 128 |
|
| 129 |
|
| 130 |
# |
| 131 |
# Reconnect node 2 |
| 132 |
# |
| 133 |
--connection node_2a |
| 134 |
SET GLOBAL wsrep_provider_options = 'gmcast.isolate = 0'; |
| 135 |
--let $wait_condition = SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' |
| 136 |
--source include/wait_condition.inc |
| 137 |
--source include/galera_wait_ready.inc |
| 138 |
SET SESSION wsrep_sync_wait = DEFAULT; |
| 139 |
|
| 140 |
--connection node_1a |
| 141 |
SET SESSION wsrep_sync_wait = 0; |
| 142 |
--let $wait_condition = SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' |
| 143 |
--source include/wait_condition.inc |
| 144 |
--source include/galera_wait_ready.inc |
| 145 |
SET SESSION wsrep_sync_wait = DEFAULT; |
| 146 |
|
| 147 |
--connection node_3a |
| 148 |
SET SESSION wsrep_sync_wait = 0; |
| 149 |
--let $wait_condition = SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' |
| 150 |
--source include/wait_condition.inc |
| 151 |
--source include/galera_wait_ready.inc |
| 152 |
SET SESSION wsrep_sync_wait = DEFAULT; |
| 153 |
|
| 154 |
|
| 155 |
# |
| 156 |
# Expect no entries in wsrep_streaming_log |
| 157 |
# |
| 158 |
--connection node_1a |
| 159 |
--let $wait_condition = SELECT COUNT(*) = 0 FROM mysql.wsrep_streaming_log |
| 160 |
--source include/wait_condition.inc |
| 161 |
SELECT COUNT(*) AS EXPECT_0 FROM mysql.wsrep_streaming_log; |
| 162 |
--connection node_2a |
| 163 |
--let $wait_condition = SELECT COUNT(*) = 0 FROM mysql.wsrep_streaming_log |
| 164 |
--source include/wait_condition.inc |
| 165 |
SELECT COUNT(*) AS EXPECT_0 FROM mysql.wsrep_streaming_log; |
| 166 |
--connection node_3a |
| 167 |
--let $wait_condition = SELECT COUNT(*) = 0 FROM mysql.wsrep_streaming_log |
| 168 |
--source include/wait_condition.inc |
| 169 |
SELECT COUNT(*) AS EXPECT_0 FROM mysql.wsrep_streaming_log; |
| 170 |
|
| 171 |
|
| 172 |
--connection node_1 |
| 173 |
DROP TABLE t1; |
| 174 |
|
| 175 |
--source ../galera/include/auto_increment_offset_restore.inc |