Debian Codegraph @

mysql-test/suite/rpl_gtid/t/rpl_gtid_sql_until_before_after.test

raw
1 # BUG#13810456: GTID: UNTIL_SQL_BEFORE_GTID DOES NOT WORK
2 #
3 # This test performs multiple invocations of
4 # START SLAVE UNTIL SQL_BEFORE_GTIDS and START SLAVE UNTIL SQL_AFTER_GTIDS
5 # to demonstrate its correct operation.
6 #
7 # Create a set of transactions on the master and applied them individually
8 # by using START SLAVE UNTIL SQL_BEFORE_GTIDS and
9 # START SLAVE UNTIL SQL_AFTER_GTIDS with different sets of missing and/or
10 # already applied GTIDs.
11 #
12 --source include/not_group_replication_plugin.inc
13 --source include/master-slave.inc
14
15 --connection master
16 --let $master_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1)
17 CREATE TABLE t1(c1 INTEGER) ENGINE= Innodb;
18 --source include/sync_slave_sql_with_master.inc
19 --echo [connection slave]
20 --source include/stop_slave.inc
21
22 # Generate a set of transactions on the master.
23 # INSERT value is the equal to sequence number.
24 --echo [connection master]
25 --connection master
26 --let $i=2
27 while ($i != 11)
28 {
29 --eval INSERT INTO t1 VALUES($i)
30 --inc $i
31 }
32
33 --connection slave
34 --echo [connection slave]
35
36 # Incorrect START SLAVE UNTIL SQL_BEFORE_GTIDS
37 --replace_result $master_uuid MASTER_UUID
38 --error ER_BAD_REPLICA_UNTIL_COND
39 --eval START SLAVE UNTIL SQL_BEFORE_GTIDS= "$master_uuid:4-5", SOURCE_LOG_FILE= 'foo.bin', SOURCE_LOG_POS= 100
40
41 # Incorrect START SLAVE UNTIL SQL_BEFORE_GTIDS
42 --replace_result $master_uuid MASTER_UUID
43 --error ER_BAD_REPLICA_UNTIL_COND
44 --eval START SLAVE SQL_THREAD UNTIL SQL_BEFORE_GTIDS= "$master_uuid:4-5", SOURCE_LOG_FILE= 'foo.bin', SOURCE_LOG_POS= 100
45
46 # Incorrect START SLAVE UNTIL SQL_BEFORE_GTIDS
47 --replace_result $master_uuid MASTER_UUID
48 --error ER_BAD_REPLICA_UNTIL_COND
49 --eval START SLAVE IO_THREAD UNTIL SQL_BEFORE_GTIDS= "$master_uuid:4-5", SOURCE_LOG_FILE= 'foo.bin', SOURCE_LOG_POS= 100
50
51 # Incorrect START SLAVE UNTIL SQL_BEFORE_GTIDS
52 --replace_result $master_uuid MASTER_UUID
53 --error ER_PARSE_ERROR
54 --eval START SLAVE FOO UNTIL SQL_BEFORE_GTIDS= "$master_uuid:4-5"
55
56 # UNTIL GTID
57 --echo Check that START SLAVE IO_THREAD UNTIL ... maintains old behaviour, condition is ignored.
58 --replace_result $master_uuid MASTER_UUID
59 --eval START SLAVE IO_THREAD UNTIL SQL_BEFORE_GTIDS= "$master_uuid:4-5"
60
61 --echo Wait until IO Thread reads all master binlog and stop slave.
62 --let $slave_param= Retrieved_Gtid_Set
63 --let $slave_param_value= $master_uuid:1-10
64 --source include/wait_for_slave_param.inc
65 --source include/stop_slave_io.inc
66
67 --echo SQL thread must stop *before* INSERT 4
68 --replace_result $master_uuid MASTER_UUID
69 --eval START SLAVE SQL_THREAD UNTIL SQL_BEFORE_GTIDS= "$master_uuid:4-5"
70 --source include/wait_for_slave_sql_to_stop.inc
71 --let $assert_cond= MAX(c1)=3 FROM t1
72 --let $assert_text= Rows until 3 in t1 must be replicated now
73 --source include/assert.inc
74
75 --echo SQL thread must stop *after* INSERT 5
76 # SQL_AFTER_GTIDS is not working fine with MTS which is 'TODO'. Hence post
77 # BUG14767986 fix 'ER_MTA_FEATURE_IS_NOT_SUPPORTED' warning will be thrown
78 # when MTS is enabled and server will be started in single threaded mode.
79 --disable_warnings
80 --replace_result $master_uuid MASTER_UUID
81 --eval START SLAVE SQL_THREAD UNTIL SQL_AFTER_GTIDS= "$master_uuid:4-5"
82 --enable_warnings
83 --source include/wait_for_slave_sql_to_stop.inc
84 --let $assert_cond= MAX(c1)=5 FROM t1
85 --let $assert_text= Rows until 5 in t1 must be replicated now
86 --source include/assert.inc
87
88 --echo SQL thread must stop *before* INSERT 6
89 --replace_result $master_uuid MASTER_UUID
90 --eval START SLAVE SQL_THREAD, IO_THREAD UNTIL SQL_BEFORE_GTIDS= "$master_uuid:2-7"
91 --source include/wait_for_slave_sql_to_stop.inc
92 --let $assert_cond= MAX(c1)=5 FROM t1
93 --let $assert_text= Rows until 5 in t1 must be replicated now
94 --source include/assert.inc
95
96 --echo SQL thread must stop *after* INSERT 5
97 --echo 1-5 are already applied so it will stop immediately
98 # SQL_AFTER_GTIDS is not working fine with MTS which is 'TODO'. Hence post
99 # BUG14767986 fix 'ER_MTA_FEATURE_IS_NOT_SUPPORTED' warning will be thrown
100 # when MTS is enabled and server will be started in single threaded mode.
101 --disable_warnings
102 --replace_result $master_uuid MASTER_UUID
103 --eval START SLAVE SQL_THREAD, IO_THREAD UNTIL SQL_AFTER_GTIDS= "$master_uuid:1-5"
104 --enable_warnings
105 --source include/wait_for_slave_sql_to_stop.inc
106 --let $assert_cond= MAX(c1)=5 FROM t1
107 --let $assert_text= Rows until 5 in t1 must be replicated now
108 --source include/assert.inc
109
110 --echo SQL thread must stop *before* INSERT 10
111 --replace_result $master_uuid MASTER_UUID
112 --enable_query_log
113 --eval START SLAVE UNTIL SQL_BEFORE_GTIDS= "$master_uuid:10"
114 --source include/wait_for_slave_sql_to_stop.inc
115 --let $assert_cond= MAX(c1)=9 FROM t1
116 --let $assert_text= Rows until 9 in t1 must be replicated now
117 --source include/assert.inc
118
119 --echo SQL thread must stop *before* INSERT 3-6
120 --echo 3-6 is already applied so it will stop immediately
121 --replace_result $master_uuid MASTER_UUID
122 --eval START SLAVE UNTIL SQL_BEFORE_GTIDS= "$master_uuid:3-6"
123 --source include/wait_for_slave_sql_to_stop.inc
124 --let $assert_cond= MAX(c1)=9 FROM t1
125 --let $assert_text= Rows until 9 in t1 must be replicated now
126 --source include/assert.inc
127
128 --echo SQL thread must stop *before* INSERT 9
129 --echo 9 is already applied so it will stop immediately
130 --replace_result $master_uuid MASTER_UUID
131 --eval START SLAVE UNTIL SQL_BEFORE_GTIDS= "$master_uuid:9"
132 --source include/wait_for_slave_sql_to_stop.inc
133 --let $assert_cond= MAX(c1)=9 FROM t1
134 --let $assert_text= Rows until 9 in t1 must be replicated now
135 --source include/assert.inc
136
137 --echo Sync slave with master
138 --source include/start_slave.inc
139 --replace_result $master_uuid MASTER_UUID
140 --disable_result_log
141 --eval SELECT WAIT_UNTIL_SQL_THREAD_AFTER_GTIDS('$master_uuid:10')
142 --enable_result_log
143 --let $assert_cond= MAX(c1)=10 FROM t1
144 --let $assert_text= Rows until 10 in t1 must be replicated now
145 --source include/assert.inc
146
147 #
148 # Bug#24976304 WAIT_UNTIL_SQL_THREAD_AFTER_GTIDS TIMEOUT VALUE HANDLES SOME
149 # INPUTS BADLY
150 #
151 --echo Test WAIT_UNTIL_SQL_THREAD_AFTER_GTIDS function with negative timeout
152 --echo value. When SQL_MODE is strict, then it will throw
153 --echo WRONG_ARGUMENTS error.
154 SET @save_sql_mode=@@SESSION.SQL_MODE;
155 SET @@SESSION.SQL_MODE="STRICT_ALL_TABLES";
156 --replace_result $master_uuid MASTER_UUID
157 --error ER_WRONG_ARGUMENTS
158 --eval SELECT WAIT_UNTIL_SQL_THREAD_AFTER_GTIDS('$master_uuid:100', -1);
159
160 --echo When SQL_MODE is non-strict mode the function executes
161 --echo same as in strict SQL_MODE and generates WRONG_ARGUMENTS error.
162 SET @@SESSION.SQL_MODE="";
163 --replace_result $master_uuid MASTER_UUID
164 --error ER_WRONG_ARGUMENTS
165 --eval SELECT WAIT_UNTIL_SQL_THREAD_AFTER_GTIDS('$master_uuid:100', -1);
166 SET @@SESSION.SQL_MODE=@save_sql_mode;
167
168 --echo Test WAIT_UNTIL_SQL_THREAD_AFTER_GTIDS function with fractional timeout
169 --echo value. Earlier(before fix), 0.4 is read as integer value '0' and
170 --echo the function hanged forever (or till all the specified gtids are
171 --echo executed). Now(after fix) 0.4 will be read as double 0.4 and will waitfor
172 --echo atleast 0.4 seconds (or till all the specified gtids are executed).
173 --echo Also check that function returns -1 if the timeout has been exceeded.
174 --let $assert_text= WAIT_UNTIL_SQL_THREAD_AFTER_GTIDS returns -1 if the timeout has been exceeded.
175 --let $query_result= query_get_value("SELECT WAIT_UNTIL_SQL_THREAD_AFTER_GTIDS('$master_uuid:100', 0.4) AS VALUE", VALUE, 1)
176 --let $assert_cond= "$query_result" = "-1"
177 --source include/assert.inc
178
179 # End of Test Bug#24976304
180
181 # Cleanup
182 --connection master
183 DROP TABLE t1;
184 --source include/rpl_end.inc