Debian Codegraph @

mysql-test/suite/group_replication/t/gr_consistent_reads_after_member_join.test

raw
1 ################################################################################
2 # Validate the correct behaviour when a member joins a group while there is a
3 # transaction with group_replication_consistency= 'AFTER' ongoing.
4 #
5 # Test:
6 # 00. The test requires three servers: M1, M2 and M3.
7 # 01. Bootstrap group with M1, add M2.
8 # 02. Create table t1 with group_replication_consistency= 'AFTER'
9 # 03. Lock table t1 on server2 to block a future update.
10 # 04. Execute transaction T1, the transaction will block since
11 # server2 cannot prepare.
12 # 05. Execute START GR on M3.
13 # The member will be in RECOVERING until T1 is complete.
14 # 06. On M2: Unlock t1.
15 # 07. server3 will change to ONLINE state.
16 # 08. Validate data.
17 # 09. Clean up.
18 ################################################################################
19 --source include/big_test.inc
20 --source include/not_have_privilege_checks_user.inc
21 --source include/have_group_replication_plugin.inc
22 --let $rpl_server_count= 3
23 --let $rpl_skip_group_replication_start= 1
24 --source include/group_replication.inc
25
26 --echo
27 --echo ############################################################
28 --echo # 01. Bootstrap group with M1, add M2.
29 --source include/start_and_bootstrap_group_replication.inc
30
31 --let $rpl_connection_name= server2
32 --source include/rpl_connection.inc
33 --source include/start_group_replication.inc
34
35
36 --echo
37 --echo ############################################################
38 --echo # 02. Create table t1 with group_replication_consistency= 'AFTER'
39 --let $rpl_connection_name= server1
40 --source include/rpl_connection.inc
41 SET @@SESSION.group_replication_consistency= 'AFTER';
42 CREATE TABLE t1 (a INT PRIMARY KEY);
43
44
45 --echo
46 --echo ############################################################
47 --echo # 03. Lock table t1 on server2 to block a future update.
48 --let $rpl_connection_name= server2
49 --source include/rpl_connection.inc
50 LOCK table t1 READ;
51
52
53 --echo
54 --echo ############################################################
55 --echo # 04. Execute transaction T1, the transaction will block since
56 --echo # server2 cannot prepare.
57 --let $rpl_connection_name= server1
58 --source include/rpl_connection.inc
59 --send INSERT INTO t1 VALUES (11)
60
61 --let $rpl_connection_name= server_1
62 --source include/rpl_connection.inc
63 --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)'
64 --source include/wait_condition.inc
65
66 --let $rpl_connection_name= server_2
67 --source include/rpl_connection.inc
68 --let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist WHERE user='system user' AND state='Waiting for table metadata lock'
69 --source include/wait_condition.inc
70
71
72 --echo
73 --echo ############################################################
74 --echo # 05. Execute START GR on M3.
75 --echo # The member will be in RECOVERING until T1 is complete.
76 --let $rpl_connection_name= server3
77 --source include/rpl_connection.inc
78 --let $group_replication_start_member_state= RECOVERING
79 --source include/start_group_replication.inc
80
81
82 --echo
83 --echo ############################################################
84 --echo # 06. On M2: Unlock t1.
85 --let $rpl_connection_name= server2
86 --source include/rpl_connection.inc
87 UNLOCK tables;
88
89
90 --echo
91 --echo ############################################################
92 --echo # 07. server3 will change to ONLINE state.
93 --let $rpl_connection_name= server3
94 --source include/rpl_connection.inc
95 --let $group_replication_member_state= ONLINE
96 --source include/gr_wait_for_member_state.inc
97
98
99 --echo
100 --echo ############################################################
101 --echo # 08. Validate data.
102 --let $rpl_connection_name= server1
103 --source include/rpl_connection.inc
104 --reap
105 --let $assert_text= 'There is 1 value in table t1'
106 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE a=11, count, 1] = 1
107 --source include/assert.inc
108
109 --let $rpl_connection_name= server2
110 --source include/rpl_connection.inc
111 --let $assert_text= 'There is 1 value in table t1'
112 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE a=11, count, 1] = 1
113 --source include/assert.inc
114
115 # server3 was not considered on the consistent transactions.
116 --source include/rpl_sync.inc
117
118 --let $rpl_connection_name= server3
119 --source include/rpl_connection.inc
120 --let $assert_text= 'There is 1 value in table t1'
121 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE a=11, count, 1] = 1
122 --source include/assert.inc
123
124 --let $diff_tables=server1:t1, server2:t1, server3:t1
125 --source include/diff_tables.inc
126
127
128 --echo
129 --echo ############################################################
130 --echo # 09. Clean up.
131 --let $rpl_connection_name= server1
132 --source include/rpl_connection.inc
133
134 DROP TABLE t1;
135 SET @@SESSION.group_replication_consistency= DEFAULT;
136
137 --source include/group_replication_end.inc