Debian Codegraph @

mysql-test/suite/binlog_gtid/t/binlog_gtid_exhausted.test

raw
1 ###############################################################################
2 # Bug#21276561: FAILURE TO GENERATE GTID LEADS TO INCONSISTENCY
3 #
4 # Problem:
5 # =======
6 # If generating a GTID for a transaction fails, the transaction is not written
7 # to the binary log but still gets committed, which potentially leads to
8 # master/slave data inconsistency.
9 #
10 # Test:
11 # =====
12 # Simulate a scenario such that generation of GTID number reaches its maximum
13 # value and the new GTID cannot be generated because of that. Verify that this
14 # fatal error case is appropriately handled as per the binlog_error_action
15 # value specified by user.
16 ###############################################################################
17 # This test case is binlog_format agnostic
18 --source include/have_binlog_format_statement.inc
19 # Don't test this under valgrind, memory leaks will occur
20 --source include/not_valgrind.inc
21
22 call mtr.add_suppression("An error occurred during flush stage of the commit");
23 call mtr.add_suppression("Attempting backtrace. You can use the following information to find out");
24
25 --let $assert_file = $MYSQLTEST_VARDIR/tmp/binlog_gtid_exhausted.err
26
27 #Test case 1:
28 SET GLOBAL binlog_error_action=IGNORE_ERROR;
29 CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
30 # @@GLOBAL.GTID_PURGED can only be set when @@GLOBAL.GTID_EXECUTED is empty.
31 # Hence execute RESET MASTER.
32 RESET MASTER;
33 SET GLOBAL gtid_purged = CONCAT(@@GLOBAL.server_uuid, ':1-9223372036854775805');
34 INSERT INTO t1 VALUES (1);
35 --error ER_GNO_EXHAUSTED
36 INSERT INTO t1 VALUES (2);
37
38 # BUG26035544 Assert that an error was logged to the server error log.
39 --let $assert_select = Impossible to generate GTID: the integer component reached the maximum value. Restart the server with a new server_uuid. Hence turning logging off for the whole duration of the MySQL server process. To turn it on again: fix the cause, shutdown the MySQL server and restart it.
40 --let $assert_count = 1
41 --let $assert_text = ER_GNO_EXHAUSTED found in server error log
42 --source include/assert_grep.inc
43
44 # Check that transaction is committed
45 --let $assert_cond = COUNT(*) = 2 FROM t1;
46 --let $assert_text = Count of elements in t1 should be 2.
47 --source include/assert.inc
48 --source include/restart_mysqld.inc
49
50 RESET MASTER;
51 DROP TABLE t1;
52
53 #Test case 2:
54 CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
55 # @@GLOBAL.GTID_PURGED can only be set when the new value
56 # includes the old one and their set difference does not overlap with
57 # @@GLOBAL.GTID_EXECUTED.
58 # RESET MASTER empties the latter and the current purged set
59 # to satisfy the above condition.
60 RESET MASTER;
61
62 # BUG#20470724 owes this check of no binlog rotation after SET
63 --let $binlog_file_0= query_get_value(SHOW MASTER STATUS, File, 1)
64 SET GLOBAL gtid_purged = CONCAT(@@GLOBAL.server_uuid, ':1-9223372036854775805');
65 --let $binlog_file_1= query_get_value(SHOW MASTER STATUS, File, 1)
66
67 --let $assert_cond = "$binlog_file_0" = "$binlog_file_1"
68 --let $assert_text = Binlog file must not rotate after SET GTID_PURGED
69 --source include/assert.inc
70
71 INSERT INTO t1 VALUES (1);
72 SET GLOBAL binlog_error_action=ABORT_SERVER;
73 --exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
74 --error ER_BINLOG_LOGGING_IMPOSSIBLE
75 INSERT INTO t1 VALUES (2);
76
77 --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
78 --enable_reconnect
79 --source include/wait_until_connected_again.inc
80
81 RESET MASTER;
82 DROP TABLE t1;
83
84 ## BUG26035544 Assert that an error was logged to the server error log.
85 --let $assert_select = Binary logging not possible. Message: Impossible to generate GTID: the integer component reached the maximum value. Restart the server with a new server_uuid. Server is being stopped.
86 --let $assert_count = 1
87 --let $assert_text = ER_GNO_EXHAUSTED server is being stopped found in server error log
88 --source include/assert_grep.inc
89
90 ##############################################################################
91 # ==== Purpose ====
92 # The purpose of this test is to verify that warning message is logged into
93 # server error log when GTID.GNO breaches the threshold limit.
94 #
95 # ==== Requirements ====
96 # Generate a warning message when GTID.GNO getting close to Max limit
97 # (i.e the last 1% of the range [(LLONG_MAX/100)*99])
98 #
99 # ==== Implementation ====
100 # 1. Set GTID value > Threshold[(LLONG_MAX/100)*99]
101 # - Update GTID value by executing SET GTID_PURGED.
102 # - Verify that warning message is logged into the error log.
103 # - Perform a transaction.
104 # - Verify that warning messages is logged into the error log.
105 # 2. Set GTID value < Threshold[(LLONG_MAX/100)*99]
106 # - Update GTID value by executing SET GTID_PURGED.
107 # - Perform a transaction.
108 # - Verify that no warning message is logged into the error log.
109 #
110 # ==== References ====
111 # Bug#26035544: 'BINLOG_ERROR_ACTION' IS SET TO 'ABORT_SERVER'. HENCE ABORTING
112 # THE SERVER
113 #
114 ###############################################################################
115
116 --source include/shutdown_mysqld.inc
117 --remove_file $MYSQLTEST_VARDIR/tmp/binlog_gtid_exhausted.err
118 --source include/start_mysqld.inc
119
120 --let $server_uuid = `SELECT @@GLOBAL.SERVER_UUID`
121 --let $assert_file = $MYSQLTEST_VARDIR/tmp/binlog_gtid_exhausted.err
122 --let $assert_select = The integer component of the GTID number is high.
123
124 # Test case 3:
125 # Test scenario set GTID > Threshold[(LLONG_MAX/100)*99].
126 RESET MASTER;
127 --disable_query_log
128 --eval SET GLOBAL gtid_purged = CONCAT('$server_uuid:1-', (1 << 63) - 10);
129 --enable_query_log
130 CREATE TABLE t1(i INT);
131
132 # Cleanup
133 DROP TABLE t1;
134
135 # Assert that a warning was logged to the server error log.
136 --let $assert_count = 3
137 --let $assert_text = ER_WARN_GTID_THRESHOLD_BREACH found in server error log
138 --source include/assert_grep.inc
139
140 # Test case 4:
141 # Test scenario set GTID < Threshold.
142 RESET MASTER;
143 --disable_query_log
144 --eval SET GLOBAL gtid_purged = CONCAT('$server_uuid:1-', (1 << 63) - (1 << 57));
145 --enable_query_log
146 CREATE TABLE t1(i INT);
147
148 # Assert that no new GTID_THRESHOLD_BREACH warning was logged to the server error log.
149 --let $assert_count= 3
150 --let $assert_text = No new ER_WARN_GTID_THRESHOLD_BREACH found in server error log
151 --source include/assert_grep.inc
152
153 # Cleanup
154 DROP TABLE t1;
155
156 ##############################################################################
157 # ==== Purpose ====
158 # The purpose of this test is to verify that, when user executes
159 # SET gtid_purged, GTID threshold breach warning message should be raised
160 # only based on the number of GTIDs in the server_uuid instead of counting
161 # all UUIDs.
162 #
163 # ==== Requirements ====
164 # A SET gtid_purged statement should not generate a warning when the range of
165 # GTIDs for server_uuid is below the limit, even if the total number of GTIDs
166 # taking all UUIDs into account exceeds the threshold.
167 #
168 # ==== Implementation ====
169 # 1. Single UUID other than server_uuid have less GTIDs than the
170 # Threshold[(INT64_MAX/100)*99] and total number of GTIDs > Threshold
171 # - Set server_uuid with a dummy value and GTID.GNO value below
172 # Threshold by executing SET GTID_PURGED.
173 # - Set server_uuid as @@GLOBAL.SERVER_UUID and GTID.GNO value below
174 # Threshold in such a way that total number of GTDs (server_uuid's
175 # GTID.GNO + previoulsy purged GTIDs) > Threshold
176 # - Verify that no warning messages is logged into the error log.
177 #
178 # 2. Single UUID other than server_uuid have more GTIDs than the
179 # Threshold[(INT64_MAX/100)*99]
180 # - Set server_uuid with a dummy value and GTID.GNO value greater than
181 # Threshold by executing SET GTID_PURGED.
182 # - Set server_uuid as @@GLOBAL.SERVER_UUID and set GTID.GNO value below
183 # Threshold
184 # - Verify that no new warning messages is logged into the error log.
185 #
186 # ==== References ====
187 # Bug#:32086209: INCORRECT DECISION TO CLONE OR RECOVER WHEN GTID
188 # DIFFERENCE IS HUGE
189 #
190 ###############################################################################
191
192 --source include/shutdown_mysqld.inc
193 --remove_file $MYSQLTEST_VARDIR/tmp/binlog_gtid_exhausted.err
194 --source include/start_mysqld.inc
195
196 --let $server_uuid = `SELECT @@server_uuid`
197 --let $dummy_server_uuid = dddddddd-dddd-dddd-dddd-dddddddddddd
198 --let $assert_file = $MYSQLTEST_VARDIR/tmp/binlog_gtid_exhausted.err
199 --let $assert_select = The integer component of the GTID number is high.
200
201 # Test scenario 1:
202 RESET MASTER;
203 # Set server_uuid as dummy and GTID value below Threshold.
204 --eval SET GLOBAL gtid_purged = CONCAT('$dummy_server_uuid:1-', (1 << 62))
205 # Set server_uuid as @@GLOBAL.SERVER_UUID and GTID below Threshold.
206 --replace_result $server_uuid SERVER_UUID
207 --eval SET GLOBAL gtid_purged = CONCAT('+$server_uuid:1-', (1 << 62))
208 # Assert that no new warning was logged to the server error log.
209 --let $assert_count = 0
210 --let $assert_text = No ER_WARN_GTID_THRESHOLD_BREACH found in server error log
211 --source include/assert_grep.inc
212
213 # Test scenario 2:
214 RESET MASTER;
215 # Set server_uuid as dummy and GTID value above Threshold.
216 --eval SET GLOBAL gtid_purged = CONCAT('$dummy_server_uuid:1-', (1 << 63) - 2)
217 # Set server_uuid as @@GLOBAL.SERVER_UUID GTID below Threshold.
218 --replace_result $server_uuid SERVER_UUID
219 --eval SET GLOBAL gtid_purged = CONCAT('+$server_uuid:1-25')
220 # Assert that no new warning was logged to the server error log.
221 --let $assert_count = 0
222 --let $assert_text = No new ER_WARN_GTID_THRESHOLD_BREACH found in server error log
223 --source include/assert_grep.inc
224
225 # Cleanup
226 --source include/restart_mysqld.inc