| 1 |
# |
| 2 |
# This test verifies that an orphaned SR gets cleanup upon cluster |
| 3 |
# reconnection. Specifically, the case where the cluster goes through |
| 4 |
# a state of no primary components, and the nodes rejoin with the |
| 5 |
# same IDs. |
| 6 |
# |
| 7 |
|
| 8 |
--source include/galera_cluster.inc |
| 9 |
|
| 10 |
--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1 |
| 11 |
--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2 |
| 12 |
|
| 13 |
# Save original auto_increment_offset values. |
| 14 |
--let $node_1=node_1 |
| 15 |
--let $node_2=node_2 |
| 16 |
--source ../galera/include/auto_increment_offset_save.inc |
| 17 |
|
| 18 |
--connection node_1 |
| 19 |
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY); |
| 20 |
|
| 21 |
SET SESSION wsrep_trx_fragment_size=1; |
| 22 |
BEGIN; |
| 23 |
INSERT INTO t1 VALUES (10); |
| 24 |
INSERT INTO t1 VALUES (11); |
| 25 |
INSERT INTO t1 VALUES (12); |
| 26 |
|
| 27 |
--connection node_2 |
| 28 |
SET SESSION wsrep_trx_fragment_size=1; |
| 29 |
BEGIN; |
| 30 |
INSERT INTO t1 VALUES (20); |
| 31 |
INSERT INTO t1 VALUES (21); |
| 32 |
INSERT INTO t1 VALUES (22); |
| 33 |
SELECT COUNT(*) `expect 6` FROM mysql.wsrep_streaming_log; |
| 34 |
|
| 35 |
# isolate node 2 |
| 36 |
--connection node_2a |
| 37 |
SET GLOBAL wsrep_provider_options = 'gmcast.isolate = 1'; |
| 38 |
SET SESSION wsrep_sync_wait = 0; |
| 39 |
--let $wait_condition = SELECT VARIABLE_VALUE = 'OFF' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready' |
| 40 |
--source include/wait_condition.inc |
| 41 |
SHOW STATUS LIKE 'wsrep_cluster_size'; |
| 42 |
SHOW STATUS LIKE 'wsrep_cluster_status'; |
| 43 |
SET SESSION wsrep_sync_wait = DEFAULT; |
| 44 |
|
| 45 |
--connection node_1a |
| 46 |
SET SESSION wsrep_sync_wait = 0; |
| 47 |
--let $wait_condition = SELECT VARIABLE_VALUE = 'OFF' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready' |
| 48 |
--source include/wait_condition.inc |
| 49 |
SHOW STATUS LIKE 'wsrep_cluster_size'; |
| 50 |
SHOW STATUS LIKE 'wsrep_cluster_status'; |
| 51 |
SET SESSION wsrep_sync_wait = DEFAULT; |
| 52 |
|
| 53 |
--connection node_2a |
| 54 |
# reconnect node 2 |
| 55 |
SET GLOBAL wsrep_provider_options = 'gmcast.isolate = 0'; |
| 56 |
--source include/galera_wait_ready.inc |
| 57 |
SHOW STATUS LIKE 'wsrep_cluster_size'; |
| 58 |
|
| 59 |
--connection node_1a |
| 60 |
# wait for reconnection and check that the streaming log has been cleared |
| 61 |
--source include/galera_wait_ready.inc |
| 62 |
SHOW STATUS LIKE 'wsrep_cluster_size'; |
| 63 |
SELECT COUNT(*) `expect 0` FROM mysql.wsrep_streaming_log; |
| 64 |
|
| 65 |
--connection node_2a |
| 66 |
# check that the streaming log has been cleared and there are no locks |
| 67 |
# from the SRs by issuing conflicting inserts |
| 68 |
SELECT COUNT(*) `expect 0` FROM mysql.wsrep_streaming_log; |
| 69 |
INSERT INTO t1 VALUES(10); |
| 70 |
INSERT INTO t1 VALUES(20); |
| 71 |
SELECT * FROM t1; |
| 72 |
|
| 73 |
# check that both SRs have been rolled back |
| 74 |
--connection node_1 |
| 75 |
--error ER_LOCK_DEADLOCK |
| 76 |
INSERT INTO t1 VALUES(13); |
| 77 |
|
| 78 |
--connection node_2 |
| 79 |
--error ER_LOCK_DEADLOCK |
| 80 |
INSERT INTO t1 VALUES(23); |
| 81 |
|
| 82 |
DROP TABLE t1; |
| 83 |
|
| 84 |
# Restore original auto_increment_offset values. |
| 85 |
--source ../galera/include/auto_increment_offset_restore.inc |