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 137
|
################################################################################
# Validate the correct behaviour when a member joins a group in single-primary
# mode while there is a transaction with group_replication_consistency= 'AFTER'
# ongoing.
#
# Test:
# 00. The test requires three servers: M1, M2 and M3.
# 01. Bootstrap group with M1, add M2.
# 02. Lock table t1 on server2 to block a future update.
# 03. Execute transaction T1, the transaction will block since
# server2 cannot prepare.
# 04. Execute START GR on M3.
# The member will be in RECOVERING until T1 is complete.
# 05. On M2: Unlock t1.
# 06. server3 will change to ONLINE state.
# 07. Validate data.
# 08. Clean up.
################################################################################
--source include/big_test.inc
--source include/have_group_replication_plugin.inc
--let $rpl_skip_group_replication_start= 1
--let $rpl_server_count= 3
--let $rpl_group_replication_single_primary_mode=1
--source include/group_replication.inc
--echo
--echo ############################################################
--echo # 01. Bootstrap group with M1, add M2.
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
--source include/start_and_bootstrap_group_replication.inc
CREATE TABLE t1 (a INT PRIMARY KEY);
INSERT INTO t1 VALUES (1);
--let $rpl_connection_name= server2
--source include/rpl_connection.inc
--source include/start_group_replication.inc
--echo
--echo ############################################################
--echo # 02. Lock table t1 on server2 to block a future update.
--let $rpl_connection_name= server2
--source include/rpl_connection.inc
LOCK TABLE t1 READ;
--echo
--echo ############################################################
--echo # 03. Execute transaction T1, the transaction will block since
--echo # server2 cannot prepare.
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
--send INSERT INTO t1 VALUES (2)
--echo ############################################################
--echo # 04. Execute START GR on M3.
--echo # The member will be in RECOVERING until T1 is complete.
--let $rpl_connection_name= server3
--source include/rpl_connection.inc
--let $group_replication_start_member_state= RECOVERING
--source include/start_group_replication.inc
# Give some time to the view clash with T1 on member1
--sleep 40
--echo
--echo ############################################################
--echo # 05. On M2: Unlock t1.
--let $rpl_connection_name= server2
--source include/rpl_connection.inc
UNLOCK TABLES;
--echo
--echo ############################################################
--echo # 06. server3 will change to ONLINE state.
--let $rpl_connection_name= server3
--source include/rpl_connection.inc
--let $group_replication_member_state= ONLINE
--source include/gr_wait_for_member_state.inc
--echo
--echo ############################################################
--echo # 07. Validate data.
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
--reap
--let $assert_text= 'There is a 1 value in table t1'
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE a=1, count, 1] = 1
--source include/assert.inc
--let $assert_text= 'There is a 2 value in table t1'
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE a=2, count, 1] = 1
--source include/assert.inc
--let $keep_gtid_events= 1
--source include/show_binlog_events.inc
--let $rpl_connection_name= server2
--source include/rpl_connection.inc
--let $assert_text= 'There is a 1 value in table t1'
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE a=1, count, 1] = 1
--source include/assert.inc
--let $assert_text= 'There is a 2 value in table t1'
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE a=2, count, 1] = 1
--source include/assert.inc
--let $keep_gtid_events= 1
--source include/show_binlog_events.inc
--let $rpl_connection_name= server3
--source include/rpl_connection.inc
--let $assert_text= 'There is a 1 value in table t1'
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE a=1, count, 1] = 1
--source include/assert.inc
--let $assert_text= 'There is a 2 value in table t1'
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE a=2, count, 1] = 1
--source include/assert.inc
--let $keep_gtid_events= 1
--source include/show_binlog_events.inc
--let $diff_tables=server1:t1, server2:t1, server3:t1
--source include/diff_tables.inc
--echo
--echo ############################################################
--echo # 08. Clean up.
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
DROP TABLE t1;
--source include/group_replication_end.inc
|