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 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. Create table t1 with group_replication_consistency= 'AFTER'
# 03. Lock table t1 on server2 to block a future update.
# 04. Execute transaction T1, the transaction will block since
# server2 cannot prepare.
# 05. Execute START GR on M3.
# The member will be in RECOVERING until T1 is complete.
# 06. On M2: Unlock t1.
# 07. server3 will change to ONLINE state.
# 08. Validate data.
# 09. Clean up.
################################################################################
--source include/big_test.inc
--source include/not_have_privilege_checks_user.inc
--source include/have_group_replication_plugin.inc
--let $rpl_server_count= 3
--let $rpl_skip_group_replication_start= 1
--source include/group_replication.inc
--echo
--echo ############################################################
--echo # 01. Bootstrap group with M1, add M2.
--source include/start_and_bootstrap_group_replication.inc
--let $rpl_connection_name= server2
--source include/rpl_connection.inc
--source include/start_group_replication.inc
--echo
--echo ############################################################
--echo # 02. Create table t1 with group_replication_consistency= 'AFTER'
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
SET @@SESSION.group_replication_consistency= 'AFTER';
CREATE TABLE t1 (a INT PRIMARY KEY);
--echo
--echo ############################################################
--echo # 03. 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 # 04. 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 (11)
--let $rpl_connection_name= server_1
--source include/rpl_connection.inc
--let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist WHERE user='root' AND state='waiting for handler commit' AND info='INSERT INTO t1 VALUES (11)'
--source include/wait_condition.inc
--let $rpl_connection_name= server_2
--source include/rpl_connection.inc
--let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist WHERE user='system user' AND state='Waiting for table metadata lock'
--source include/wait_condition.inc
--echo
--echo ############################################################
--echo # 05. 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
--echo
--echo ############################################################
--echo # 06. On M2: Unlock t1.
--let $rpl_connection_name= server2
--source include/rpl_connection.inc
UNLOCK tables;
--echo
--echo ############################################################
--echo # 07. 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 # 08. Validate data.
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
--reap
--let $assert_text= 'There is 1 value in table t1'
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE a=11, count, 1] = 1
--source include/assert.inc
--let $rpl_connection_name= server2
--source include/rpl_connection.inc
--let $assert_text= 'There is 1 value in table t1'
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE a=11, count, 1] = 1
--source include/assert.inc
# server3 was not considered on the consistent transactions.
--source include/rpl_sync.inc
--let $rpl_connection_name= server3
--source include/rpl_connection.inc
--let $assert_text= 'There is 1 value in table t1'
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE a=11, count, 1] = 1
--source include/assert.inc
--let $diff_tables=server1:t1, server2:t1, server3:t1
--source include/diff_tables.inc
--echo
--echo ############################################################
--echo # 09. Clean up.
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
DROP TABLE t1;
SET @@SESSION.group_replication_consistency= DEFAULT;
--source include/group_replication_end.inc
|