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
|
###############################################################################
#
# Outside the scope of configurations changes, if a primary member fails
# the new primary wont be writable until it executes all
# the transactions from the old primary.
#
# Test:
# 0. This test requires three servers
# 1. Test starts in Single primary mode with server1 as primary
# 2. Set weight on server2 to be the next elected primary and join to
# the group
# 3. Add server3 to group
# 4. Lock table on the new primary (server 2)
# 5. Execute a transaction that will stuck
# 6. Stop server1
# 7. Server2 will wait for buffered transactions on read only mode
# 8. Unlock table on server2
# 9. Server2 will apply buffered transactions and disable read only mode
# 10. Assert server2 is primary server
# 11. Cleanup
#
###############################################################################
--source include/big_test.inc
--source include/have_group_replication_plugin.inc
--let $rpl_skip_group_replication_start= 1
--let $rpl_group_replication_single_primary_mode=1
--let $rpl_server_count= 3
--source include/group_replication.inc
--echo
--echo # 1. Test starts in Single primary mode with server1 as primary
--let $server1_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1)
--source include/start_and_bootstrap_group_replication.inc
CREATE TABLE t1(a int primary key);
--let $rpl_connection_name= server2
--source include/rpl_connection.inc
--echo
--echo # 2. Set weight on server2 to be the next elected primary and join to
--echo # the group
SET @@GLOBAL.group_replication_member_weight= 90;
--source include/start_group_replication.inc
--echo
--echo # 3. Add server3 to group
--let $rpl_connection_name= server3
--source include/rpl_connection.inc
--source include/start_group_replication.inc
--echo
--echo # 4. Lock table on the new primary (server 2)
--let $rpl_connection_name= server_2
--source include/rpl_connection.inc
LOCK TABLE t1 READ;
--echo
--echo # 5. Execute a transaction that will stuck
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
INSERT INTO t1 VALUES (1);
--echo
--echo # 6. Stop server1
--source include/stop_group_replication.inc
--echo
--echo # 7. Server2 will wait for buffered transactions on read only mode
--let $rpl_connection_name= server2
--source include/rpl_connection.inc
--let $wait_condition=SELECT COUNT(*)=1 FROM performance_schema.events_stages_current WHERE event_name LIKE "stage/group_rpl/Primary Election: applying buffered transactions"
--source include/wait_condition.inc
--let $wait_condition= SELECT @@GLOBAL.super_read_only = '1'
--source include/wait_condition.inc
--echo
--echo # 8. Unlock table on server2
--let $rpl_connection_name= server_2
--source include/rpl_connection.inc
UNLOCK TABLES;
--echo
--echo # 9. Server2 will apply buffered transactions and disable read only mode
--let $wait_condition= SELECT @@GLOBAL.super_read_only = '0'
--source include/wait_condition.inc
--echo
--echo # 10. Assert server2 is primary server
--source include/gr_assert_primary_member.inc
--echo
--echo # 11. Cleanup
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
--source include/start_group_replication.inc
--let $rpl_connection_name= server2
--source include/rpl_connection.inc
SET @@GLOBAL.group_replication_member_weight= DEFAULT;
DROP TABLE t1;
--let $rpl_group_replication_reset_persistent_vars=1
--source include/group_replication_end.inc
|