Debian Codegraph @

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

raw
1 ################################################################################
2 # Validate that group_replication_consistency= 'AFTER' only engage ONLINE members.
3 #
4 # Test:
5 # 00. The test requires three servers: M1, M2 and M3.
6 # 01. Create a table on server1 without log into the binlog.
7 # Bootstrap the group.
8 # Execute transaction T1.
9 # 02. Create a table on server2 without log into the binlog.
10 # Join the group.
11 # 03. Create a table on server3 without log into the binlog.
12 # Lock the table to block a future update.
13 # Join the group.
14 # 04. Execute transaction T2.
15 # Since server3 is RECOVERING it will not be engaged on
16 # the AFTER consistency, only server 1 and 2 will participate.
17 # 05. Validate data.
18 # 06. Resume recovery on server3.
19 # Validate that all servers have the same data.
20 # 07. Clean up.
21 ################################################################################
22 --source include/have_group_replication_plugin.inc
23 --let $rpl_server_count= 3
24 --let $rpl_skip_group_replication_start= 1
25 --source include/group_replication.inc
26
27 --echo
28 --echo ############################################################
29 --echo # 01. Create a table on server1 without log into the binlog.
30 --echo # Bootstrap the group.
31 --echo # Execute transaction T1.
32 --let $rpl_connection_name= server1
33 --source include/rpl_connection.inc
34 SET SESSION sql_log_bin= 0;
35 CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY);
36 SET SESSION sql_log_bin= 1;
37
38 --source include/start_and_bootstrap_group_replication.inc
39 # T1
40 INSERT INTO t1 VALUES (1);
41
42
43 --echo
44 --echo ############################################################
45 --echo # 02. Create a table on server2 without log into the binlog.
46 --echo # Join the group.
47 --let $rpl_connection_name= server2
48 --source include/rpl_connection.inc
49 SET SESSION sql_log_bin= 0;
50 CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY);
51 SET SESSION sql_log_bin= 1;
52
53 --source include/start_group_replication.inc
54
55
56 --echo
57 --echo ############################################################
58 --echo # 03. Create a table on server3 without log into the binlog.
59 --echo # Lock the table to block a future update.
60 --echo # Join the group.
61 --let $rpl_connection_name= server_3
62 --source include/rpl_connection.inc
63 SET SESSION sql_log_bin= 0;
64 CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY);
65 SET SESSION sql_log_bin= 1;
66
67 LOCK table t1 READ;
68
69 --let $rpl_connection_name= server3
70 --source include/rpl_connection.inc
71 --let $group_replication_start_member_state= RECOVERING
72 --source include/start_group_replication.inc
73
74
75 --echo
76 --echo ############################################################
77 --echo # 04. Execute transaction T2.
78 --echo # Since server3 is RECOVERING it will not be engaged on
79 --echo # the AFTER consistency, only server 1 and 2 will participate.
80 --let $rpl_connection_name= server1
81 --source include/rpl_connection.inc
82 # T2
83 INSERT INTO t1 VALUES (2);
84
85
86 --echo
87 --echo ############################################################
88 --echo # 05. Validate data.
89 --let $rpl_connection_name= server1
90 --source include/rpl_connection.inc
91 --let $assert_text= 'There is 1 value in table t1'
92 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE c1=1, count, 1] = 1
93 --source include/assert.inc
94 --let $assert_text= 'There is 2 value in table t1'
95 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE c1=2, count, 1] = 1
96 --source include/assert.inc
97
98 --let $rpl_connection_name= server2
99 --source include/rpl_connection.inc
100 --let $assert_text= 'There is 1 value in table t1'
101 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE c1=1, count, 1] = 1
102 --source include/assert.inc
103 --let $assert_text= 'There is 2 value in table t1'
104 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE c1=2, count, 1] = 1
105 --source include/assert.inc
106
107 --let $rpl_connection_name= server3
108 --source include/rpl_connection.inc
109 --let $assert_text= 'There is no 1 value in table t1'
110 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE c1=1, count, 1] = 0
111 --source include/assert.inc
112 --let $assert_text= 'There is no 2 value in table t1'
113 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE c1=2, count, 1] = 0
114 --source include/assert.inc
115
116
117 --echo
118 --echo ############################################################
119 --echo # 06. Resume recovery on server3.
120 --echo # Validate that all servers have the same data.
121 --let $rpl_connection_name= server_3
122 --source include/rpl_connection.inc
123 UNLOCK TABLES;
124
125 --let $group_replication_member_state= ONLINE
126 --source include/gr_wait_for_member_state.inc
127
128 # Needed since server3 was not considered on T2.
129 --source include/rpl_sync.inc
130 --let $diff_tables=server1:t1, server2:t1, server3:t1
131 --source include/diff_tables.inc
132
133
134 --echo
135 --echo ############################################################
136 --echo # 07. Clean up.
137 --let $rpl_connection_name= server1
138 --source include/rpl_connection.inc
139 DROP TABLE t1;
140
141 --source include/group_replication_end.inc