Debian Codegraph @

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

raw
1 ################################################################################
2 # WL#6833: GCS Replication: Read-set free Certification
3 # Module (DBSM Snapshot Isolation)
4 #
5 # Scenario 4: Check that certifier garbage collector don't remove needed
6 # certification info to detect conflicting transactions.
7 #
8 # Verify Group Replication certifier garbage collection behavior when we have a
9 # slow applying member, that is, server 2 certifies transactions but is unable
10 # to apply remote transactions.
11 #
12 # Test:
13 # 0. The test requires two servers: M1 and M2.
14 # 1. Both members are ONLINE. Execute two transactions on M1 and wait until they
15 # are applied on all group members.
16 # 2. Block M2 group replication applier so that certified remote transactions not
17 # applied. This will mimic a slow server.
18 # 3. Commit a transaction(T1) on M1, that will be certified on both members but
19 # only applied on M1
20 # 4. Wait until M2 receives and certifies T1.
21 # 5. Wait for stable set propagation and certification info garbage collection.
22 # After garbage collection certification info will contain:
23 # WS: t1.c1=1 -> 8a94f357-aab4-11df-86ab-c80aa9422222:1-4
24 # WS: t1.c1=2 -> 8a94f357-aab4-11df-86ab-c80aa9422222:1-4
25 # 6. Execute the same statement of T1 in M2, now named T2. It must be aborted
26 # since it conflicts with T1, despite it is not yet applied on M2.
27 # Snapshot of T2 is: 8a94f357-aab4-11df-86ab-c80aa9422222:1-4
28 # 7. Resume M2 group replication applier so that certified remote transactions
29 # are applied. Wait until all group transactions are applied.
30 # 8. Execute a transaction on M2 to verify that everything is OK.
31 # 9. Check that GTID_EXECUTED on M1 contains all transactions. Also check that
32 # data is on tables.
33 # 10. Check that GTID_EXECUTED on M2 contains all transactions. Also check that
34 # data is on tables.
35 # 11. Clean up.
36 ################################################################################
37 --source include/big_test.inc
38 --source include/have_debug_sync.inc
39 --source include/have_group_replication_gtid_assignment_block_size_1.inc
40 --let $group_replication_group_name= 8a94f357-aab4-11df-86ab-c80aa9422222
41 --source include/have_group_replication_plugin.inc
42 --source include/group_replication.inc
43
44 # Keep binary logs with only GTIDs from test.
45 --connection server1
46 SET SESSION sql_log_bin= 0;
47 --source include/gtid_utils.inc
48 SET SESSION sql_log_bin= 1;
49 --connection server2
50 SET SESSION sql_log_bin= 0;
51 --source include/gtid_utils.inc
52 SET SESSION sql_log_bin= 1;
53
54
55 --echo
56 --echo ############################################################
57 --echo # 1. Execute two transactions on server 1 and wait until
58 --echo # they are applied on all group members.
59 --connection server1
60 CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
61 INSERT INTO t1 VALUES (1);
62 --source include/rpl_sync.inc
63
64
65 --echo
66 --echo ############################################################
67 --echo # 2. Block server 2 group replication applier so that
68 --echo # certified remote transactions are not applied.
69 --echo # This will mimic a slow server.
70 --connection server2
71 SET @@GLOBAL.DEBUG='+d,block_applier_updates';
72
73 --echo
74 --echo ############################################################
75 --echo # 3. Commit a transaction (T1) on server 1, that will be
76 --echo # certified on both members but only applied on server 1.
77 --connection server1
78
79 --let $assert_text= GTID_EXECUTED must contain first two transactions plus the view changes
80 --let $assert_cond= GTID_IS_EQUAL(@@GLOBAL.GTID_EXECUTED, "$group_replication_group_name:1-4")
81 --source include/assert.inc
82
83 UPDATE t1 SET c1=2 WHERE c1=1;
84
85
86 --echo
87 --echo ############################################################
88 --echo # 4. Wait until server 2 receives and certifies T1.
89 --connection server2
90
91 --let $wait_condition= SELECT Last_Conflict_Free_Transaction = '8a94f357-aab4-11df-86ab-c80aa9422222:5' from performance_schema.replication_group_member_stats where member_id in (SELECT @@server_uuid)
92 --source include/wait_condition.inc
93
94 --echo
95 --echo ############################################################
96 --echo # 5. Wait for stable set propagation and certification info
97 --echo # garbage collection.
98 --echo # After garbage collection certification info will contain:
99 --echo # WS: t1.c1=1 -> 8a94f357-aab4-11df-86ab-c80aa9422222:1-4
100 --echo # WS: t1.c1=2 -> 8a94f357-aab4-11df-86ab-c80aa9422222:1-4
101 --connection server1
102 --let $wait_timeout= 65
103 --let $wait_condition= SELECT Transactions_committed_all_members<>"" FROM performance_schema.replication_group_member_stats where member_id in (SELECT @@server_uuid)
104 --source include/wait_condition.inc
105
106 --connection server1
107 --let $count_transactions_validating= query_get_value(SELECT Count_transactions_rows_validating from performance_schema.replication_group_member_stats where member_id in (SELECT @@server_uuid), Count_transactions_rows_validating, 1)
108 --let $assert_text= 'Count_transactions_rows_validating must be 2'
109 --let $assert_cond= $count_transactions_validating = 2
110 --source include/assert.inc
111
112 --let $transactions_committed_all_members= query_get_value(SELECT Transactions_committed_all_members from performance_schema.replication_group_member_stats where member_id in (SELECT @@server_uuid), Transactions_committed_all_members, 1)
113 --let $assert_text= 'Transactions_committed_all_members must be equal to $group_replication_group_name:1-4'
114 --let $assert_cond= GTID_IS_EQUAL("$transactions_committed_all_members", "$group_replication_group_name:1-4")
115 --source include/assert.inc
116
117 --connection server2
118 --let $count_transactions_validating= query_get_value(SELECT Count_transactions_rows_validating from performance_schema.replication_group_member_stats where member_id in (SELECT @@server_uuid), Count_transactions_rows_validating, 1)
119 --let $assert_text= 'Count_transactions_rows_validating must be 2'
120 --let $assert_cond= $count_transactions_validating = 2
121 --source include/assert.inc
122
123 --let $transactions_committed_all_members= query_get_value(SELECT Transactions_committed_all_members from performance_schema.replication_group_member_stats where member_id in (SELECT @@server_uuid), Transactions_committed_all_members, 1)
124 --let $assert_text= 'Transactions_committed_all_members must be equal to $group_replication_group_name:1-4'
125 --let $assert_cond= GTID_IS_EQUAL("$transactions_committed_all_members", "$group_replication_group_name:1-4")
126 --source include/assert.inc
127
128
129 --echo
130 --echo ############################################################
131 --echo # 6. Execute the same statement of T1 in server 2, now named T2.
132 --echo # It must be aborted since it conflicts with T1, despite
133 --echo # it is not yet applied on server 2. Snapshot of T2 is
134 --echo # 8a94f357-aab4-11df-86ab-c80aa9422222:1-4
135 --connection server2
136
137 --let $assert_text= GTID_EXECUTED must contain first two transactions
138 --let $assert_cond= GTID_IS_EQUAL(@@GLOBAL.GTID_EXECUTED, "$group_replication_group_name:1-4")
139 --source include/assert.inc
140
141 --error ER_TRANSACTION_ROLLBACK_DURING_COMMIT
142 UPDATE t1 SET c1=2 WHERE c1=1;
143
144 --let $assert_text= 'There is a value 1 in table t1'
145 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 1, count, 1] = 1
146 --source include/assert.inc
147 --let $assert_text= 'There is no value 2 in table t1'
148 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 2, count, 1] = 0
149 --source include/assert.inc
150
151
152 --echo
153 --echo ############################################################
154 --echo # 7. Start server 2 group replication applier so that
155 --echo # certified remote transactions are applied.
156 --echo # Wait until all group transactions are applied.
157 --connection server2
158
159 SET DEBUG_SYNC = "now WAIT_FOR applier_read_blocked";
160 SET @@GLOBAL.DEBUG='-d,block_applier_updates';
161 SET DEBUG_SYNC = "now SIGNAL resume_applier_read";
162
163 --source include/rpl_sync.inc
164
165 --echo
166 --echo ############################################################
167 --echo # 8. Execute a transaction on server 2 to verify that
168 --echo # everything is OK.
169 --connection server2
170
171 --let $assert_text= GTID_EXECUTED must contain all group transactions
172 --let $assert_cond= GTID_IS_EQUAL(@@GLOBAL.GTID_EXECUTED, "$group_replication_group_name:1-5")
173 --source include/assert.inc
174
175 UPDATE t1 SET c1=3 WHERE c1=2;
176
177 --source include/rpl_sync.inc
178
179
180 --echo ############################################################
181 --echo # 9. Check that GTID_EXECUTED on server 1 contains all
182 --echo # transactions.
183 --echo # Also check that data is on tables.
184 --connection server1
185
186 --let $assert_text= GTID_EXECUTED must contain all committed GTIDs
187 --let $assert_cond= GTID_IS_EQUAL(@@GLOBAL.GTID_EXECUTED, "$group_replication_group_name:1-6")
188 --source include/assert.inc
189
190 --let $assert_text= 'There is a value 3 in table t1'
191 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 3, count, 1] = 1
192 --source include/assert.inc
193
194
195 --echo ############################################################
196 --echo # 10. Check that GTID_EXECUTED on server 2 contains all
197 --echo # transactions.
198 --echo # Also check that data is on tables.
199 --connection server2
200
201 --let $assert_text= GTID_EXECUTED must contain all committed GTIDs
202 --let $assert_cond= GTID_IS_EQUAL(@@GLOBAL.GTID_EXECUTED, "$group_replication_group_name:1-6")
203 --source include/assert.inc
204
205 --let $assert_text= 'There is a value 3 in table t1'
206 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 3, count, 1] = 1
207 --source include/assert.inc
208
209
210 --echo
211 --echo ############################################################
212 --echo # 11. Clean up.
213 DROP TABLE t1;
214
215 --connection server1
216 SET SESSION sql_log_bin= 0;
217 --source include/gtid_utils_end.inc
218 SET SESSION sql_log_bin= 1;
219 --connection server2
220 SET SESSION sql_log_bin= 0;
221 --source include/gtid_utils_end.inc
222 SET SESSION sql_log_bin= 1;
223 SET DEBUG_SYNC= 'RESET';
224
225 --source include/group_replication_end.inc