Debian Codegraph @

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

raw
1 ################################################################################
2 # Validate group_replication_consistency= 'AFTER' behaviour against transactions
3 # coming from asynchronous channels, they shall block until precedent prepared
4 # consistent transactions are committed.
5 #
6 # Test:
7 # 00. The test requires three servers: M1, M2 and M3.
8 # 01. Bootstrap group with M1, add M2.
9 # 02. Replicate from server3 into server2.
10 # 03. Make server2 block before send its prepare message.
11 # 04. Execute T1 on server1 with
12 # @@SESSION.group_replication_consistency= 'AFTER'
13 # 05. Wait until T1 is prepared on server2.
14 # 06. Execute T2 on server3, it will wait for T1 on server2.
15 # 07. Make server2 do send its prepare message.
16 # 08. Validate data.
17 # 09. Clean up.
18 ################################################################################
19 --source include/big_test.inc
20 --source include/have_debug_sync.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. Replicate from server3 into server2.
39 --let $rpl_connection_name= server2
40 --source include/rpl_connection.inc
41 --replace_result $SERVER_MYPORT_3 SERVER_3_PORT
42 --eval CHANGE REPLICATION SOURCE TO SOURCE_HOST='localhost', SOURCE_USER='root', SOURCE_PORT=$SERVER_MYPORT_3 for channel 'ch3_2'
43
44 --let $rpl_channel_name='ch3_2'
45 --source include/start_slave.inc
46
47 --let $rpl_connection_name= server3
48 --source include/rpl_connection.inc
49 CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY);
50
51 --let $rpl_connection_name= server1
52 --source include/rpl_connection.inc
53 --let $wait_condition= SELECT COUNT(*)=1 FROM information_schema.tables WHERE (table_schema='test') AND (table_name='t1')
54 --source include/wait_condition.inc
55
56 --let $rpl_connection_name= server2
57 --source include/rpl_connection.inc
58 --let $wait_condition= SELECT COUNT(*)=1 FROM information_schema.tables WHERE (table_schema='test') AND (table_name='t1')
59 --source include/wait_condition.inc
60
61
62 --echo
63 --echo ############################################################
64 --echo # 03. Make server2 block before send its prepare message.
65 --let $rpl_connection_name= server2
66 --source include/rpl_connection.inc
67 SET @@GLOBAL.DEBUG= '+d,group_replication_wait_before_message_send_after_applier_prepare';
68
69
70 --echo
71 --echo ############################################################
72 --echo # 04. Execute T1 on server1 with
73 --echo # @@SESSION.group_replication_consistency= 'AFTER'
74 --let $rpl_connection_name= server1
75 --source include/rpl_connection.inc
76 SET @@SESSION.group_replication_consistency= 'AFTER';
77 --send INSERT INTO t1 VALUES (1)
78
79
80 --echo
81 --echo ############################################################
82 --echo # 05. Wait until T1 is prepared on server2.
83 --let $rpl_connection_name= server2
84 --source include/rpl_connection.inc
85 # Wait for the debug sync to be reached.
86 SET DEBUG_SYNC= "now WAIT_FOR signal.after_before_message_send_after_applier_prepare_waiting";
87
88
89 --echo
90 --echo ############################################################
91 --echo # 06. Execute T2 on server3, it will wait for T1 on server2.
92 --let $rpl_connection_name= server3
93 --source include/rpl_connection.inc
94 INSERT INTO t1 VALUES (3);
95
96 --let $rpl_connection_name= server2
97 --source include/rpl_connection.inc
98 --let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist WHERE user='system user' AND state='Executing hook on transaction begin.' AND info='BEGIN'
99 --source include/wait_condition.inc
100
101
102 --echo
103 --echo ############################################################
104 --echo # 07. Make server2 do send its prepare message.
105 --let $rpl_connection_name= server2
106 --source include/rpl_connection.inc
107 # Signal debug sync to continue.
108 SET DEBUG_SYNC= 'now SIGNAL signal.after_before_message_send_after_applier_prepare_continue';
109 SET @@GLOBAL.DEBUG= '-d,group_replication_wait_before_message_send_after_applier_prepare';
110
111
112 --echo
113 --echo ############################################################
114 --echo # 08. Validate data.
115 # Wait for T2
116 --source include/rpl_sync.inc
117
118 --let $rpl_connection_name= server1
119 --source include/rpl_connection.inc
120 --reap
121 SET @@SESSION.group_replication_consistency= DEFAULT;
122
123 --let $assert_text= 'There is a 1 value in table t1'
124 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE c1=1, count, 1] = 1
125 --source include/assert.inc
126 --let $wait_condition=SELECT COUNT(*)=1 FROM t1 WHERE c1=3
127 --source include/wait_condition.inc
128
129 --let $rpl_connection_name= server2
130 --source include/rpl_connection.inc
131 --let $assert_text= 'There is a 1 value in table t1'
132 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE c1=1, count, 1] = 1
133 --source include/assert.inc
134 --let $wait_condition=SELECT COUNT(*)=1 FROM t1 WHERE c1=3
135 --source include/wait_condition.inc
136
137 --let $rpl_connection_name= server3
138 --source include/rpl_connection.inc
139 --let $assert_text= 'There is no 1 value in table t1'
140 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE c1=1, count, 1] = 0
141 --source include/assert.inc
142 --let $assert_text= 'There is a 3 value in table t1'
143 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE c1=3, count, 1] = 1
144 --source include/assert.inc
145
146 --let $diff_tables=server1:t1, server2:t1
147 --source include/diff_tables.inc
148
149
150 --echo
151 --echo ############################################################
152 --echo # 09. Clean up.
153 --let $rpl_connection_name= server3
154 --source include/rpl_connection.inc
155 DROP TABLE t1;
156
157 --let $rpl_connection_name= server1
158 --source include/rpl_connection.inc
159 --let $wait_condition= SELECT COUNT(*)=0 FROM information_schema.tables WHERE (table_schema='test') AND (table_name='t1')
160 --source include/wait_condition.inc
161
162 --let $rpl_connection_name= server2
163 --source include/rpl_connection.inc
164 --let $wait_condition= SELECT COUNT(*)=0 FROM information_schema.tables WHERE (table_schema='test') AND (table_name='t1')
165 --source include/wait_condition.inc
166
167 SET DEBUG_SYNC= 'RESET';
168
169 --let $rpl_channel_name='ch3_2'
170 --source include/stop_slave.inc
171 --let $rpl_channel_name=
172 RESET SLAVE ALL FOR CHANNEL 'ch3_2';
173
174 --source include/group_replication_end.inc