|
| 1 | +delimiter ||; |
| 2 | + |
| 3 | +use mtr|| |
| 4 | + |
| 5 | +-- |
| 6 | +-- Load table with the patterns that are considered |
| 7 | +-- as suspicious and should be examined further |
| 8 | +-- |
| 9 | +CREATE TABLE suspicious_patterns ( |
| 10 | + pattern VARCHAR(255) |
| 11 | +)|| |
| 12 | + |
| 13 | + |
| 14 | +-- |
| 15 | +-- Declare a trigger that makes sure |
| 16 | +-- no invalid patterns can be inserted |
| 17 | +-- into suspicious_patterns |
| 18 | +-- |
| 19 | +/*!50002 |
| 20 | +CREATE DEFINER=root@localhost TRIGGER sp_insert |
| 21 | +BEFORE INSERT ON suspicious_patterns |
| 22 | +FOR EACH ROW BEGIN |
| 23 | + DECLARE dummy INT; |
| 24 | + SELECT "" REGEXP NEW.pattern INTO dummy; |
| 25 | +END |
| 26 | +*/|| |
| 27 | + |
| 28 | + |
| 29 | +-- |
| 30 | +-- Insert patterns for the lines we should check |
| 31 | +-- |
| 32 | +INSERT INTO suspicious_patterns VALUES |
| 33 | + ("^Warning:|mysqld: Warning|\\[Warning\\]"), |
| 34 | + ("^Error:|\\[ERROR\\]"), |
| 35 | + ("^==.* at 0x"), |
| 36 | + ("InnoDB: Warning"), |
| 37 | + ("^safe_mutex:|allocated at line"), |
| 38 | + ("missing DBUG_RETURN"), |
| 39 | + ("Attempting backtrace"), |
| 40 | + ("Assertion .* failed")|| |
| 41 | + |
| 42 | + |
| 43 | +-- |
| 44 | +-- Create table where testcases can insert patterns to |
| 45 | +-- be supressed |
| 46 | +-- |
| 47 | +CREATE TABLE test_supressions ( |
| 48 | + pattern VARCHAR(255) |
| 49 | +)|| |
| 50 | + |
| 51 | + |
| 52 | +-- |
| 53 | +-- Declare a trigger that makes sure |
| 54 | +-- no invalid patterns can be inserted |
| 55 | +-- into test_supressions |
| 56 | +-- |
| 57 | +/*!50002 |
| 58 | +CREATE DEFINER=root@localhost TRIGGER ts_insert |
| 59 | +BEFORE INSERT ON test_supressions |
| 60 | +FOR EACH ROW BEGIN |
| 61 | + DECLARE dummy INT; |
| 62 | + SELECT "" REGEXP NEW.pattern INTO dummy; |
| 63 | +END |
| 64 | +*/|| |
| 65 | + |
| 66 | + |
| 67 | +-- |
| 68 | +-- Load table with patterns that will be supressed globally(always) |
| 69 | +-- |
| 70 | +CREATE TABLE global_supressions ( |
| 71 | + pattern VARCHAR(255) |
| 72 | +)|| |
| 73 | + |
| 74 | + |
| 75 | +-- Declare a trigger that makes sure |
| 76 | +-- no invalid patterns can be inserted |
| 77 | +-- into global_supressions |
| 78 | +-- |
| 79 | +/*!50002 |
| 80 | +CREATE DEFINER=root@localhost TRIGGER gs_insert |
| 81 | +BEFORE INSERT ON global_supressions |
| 82 | +FOR EACH ROW BEGIN |
| 83 | + DECLARE dummy INT; |
| 84 | + SELECT "" REGEXP NEW.pattern INTO dummy; |
| 85 | +END |
| 86 | +*/|| |
| 87 | + |
| 88 | + |
| 89 | + |
| 90 | +-- |
| 91 | +-- Insert patterns that should always be supressed |
| 92 | +-- |
| 93 | +INSERT INTO global_supressions VALUES |
| 94 | + ("'SELECT UNIX_TIMESTAMP\\(\\)' failed on master"), |
| 95 | + ("Aborted connection"), |
| 96 | + ("Client requested master to start replication from impossible position"), |
| 97 | + ("Could not find first log file name in binary log"), |
| 98 | + ("Enabling keys got errno"), |
| 99 | + ("Error reading master configuration"), |
| 100 | + ("Error reading packet"), |
| 101 | + ("Event Scheduler"), |
| 102 | + ("Failed to open log"), |
| 103 | + ("Failed to open the existing master info file"), |
| 104 | + ("Forcing shutdown of [0-9]* plugins"), |
| 105 | + |
| 106 | + /* |
| 107 | + Due to timing issues, it might be that this warning |
| 108 | + is printed when the server shuts down and the |
| 109 | + computer is loaded. |
| 110 | + */ |
| 111 | + |
| 112 | + ("Got error [0-9]* when reading table"), |
| 113 | + ("Incorrect definition of table"), |
| 114 | + ("Incorrect information in file"), |
| 115 | + ("InnoDB: Warning: we did not need to do crash recovery"), |
| 116 | + ("Invalid \\(old\\?\\) table or database name"), |
| 117 | + ("Lock wait timeout exceeded"), |
| 118 | + ("Log entry on master is longer than max_allowed_packet"), |
| 119 | + ("unknown option '--loose-"), |
| 120 | + ("unknown variable 'loose-"), |
| 121 | + ("You have forced lower_case_table_names to 0 through a command-line option"), |
| 122 | + ("Setting lower_case_table_names=2"), |
| 123 | + ("NDB Binlog:"), |
| 124 | + ("NDB: failed to setup table"), |
| 125 | + ("NDB: only row based binary logging"), |
| 126 | + ("Neither --relay-log nor --relay-log-index were used"), |
| 127 | + ("Query partially completed"), |
| 128 | + ("Slave I.O thread aborted while waiting for relay log"), |
| 129 | + ("Slave SQL thread is stopped because UNTIL condition"), |
| 130 | + ("Slave SQL thread retried transaction"), |
| 131 | + ("Slave \\(additional info\\)"), |
| 132 | + ("Slave: .*Duplicate column name"), |
| 133 | + ("Slave: .*master may suffer from"), |
| 134 | + ("Slave: According to the master's version"), |
| 135 | + ("Slave: Column [0-9]* type mismatch"), |
| 136 | + ("Slave: Error .* doesn't exist"), |
| 137 | + ("Slave: Error .*Deadlock found"), |
| 138 | + ("Slave: Error .*Unknown table"), |
| 139 | + ("Slave: Error in Write_rows event: "), |
| 140 | + ("Slave: Field .* of table .* has no default value"), |
| 141 | + ("Slave: Field .* doesn't have a default value"), |
| 142 | + ("Slave: Query caused different errors on master and slave"), |
| 143 | + ("Slave: Table .* doesn't exist"), |
| 144 | + ("Slave: Table width mismatch"), |
| 145 | + ("Slave: The incident LOST_EVENTS occured on the master"), |
| 146 | + ("Slave: Unknown error.* 1105"), |
| 147 | + ("Slave: Can't drop database.* database doesn't exist"), |
| 148 | + ("Slave SQL:.*(Error_code: \[\[:digit:\]\]+|Query:.*)"), |
| 149 | + ("Sort aborted"), |
| 150 | + ("Time-out in NDB"), |
| 151 | + ("Warning:\s+One can only use the --user.*root"), |
| 152 | + ("Warning:\s+Setting lower_case_table_names=2"), |
| 153 | + ("Warning:\s+Table:.* on (delete|rename)"), |
| 154 | + ("You have an error in your SQL syntax"), |
| 155 | + ("deprecated"), |
| 156 | + ("description of time zone"), |
| 157 | + ("equal MySQL server ids"), |
| 158 | + ("error .*connecting to master"), |
| 159 | + ("error reading log entry"), |
| 160 | + ("lower_case_table_names is set"), |
| 161 | + ("skip-name-resolve mode"), |
| 162 | + ("slave SQL thread aborted"), |
| 163 | + ("Slave: .*Duplicate entry"), |
| 164 | + |
| 165 | + /* |
| 166 | + Special case, made as specific as possible, for: |
| 167 | + Bug #28436: Incorrect position in SHOW BINLOG EVENTS causes |
| 168 | + server coredump |
| 169 | + */ |
| 170 | + |
| 171 | + ("Error in Log_event::read_log_event\\\(\\\): 'Sanity check failed', data_len: 258, event_type: 49"), |
| 172 | + |
| 173 | + ("Statement is not safe to log in statement format"), |
| 174 | + |
| 175 | + /* test case for Bug#bug29807 copies a stray frm into database */ |
| 176 | + ("InnoDB: Error: table `test`.`bug29807` does not exist in the InnoDB internal"), |
| 177 | + ("Cannot find or open table test\/bug29807 from"), |
| 178 | + |
| 179 | + /* innodb foreign key tests that fail in ALTER or RENAME produce this */ |
| 180 | + ("InnoDB: Error: in ALTER TABLE `test`.`t[12]`"), |
| 181 | + ("InnoDB: Error: in RENAME TABLE table `test`.`t1`"), |
| 182 | + ("InnoDB: Error: table `test`.`t[12]` does not exist in the InnoDB internal"), |
| 183 | + |
| 184 | + /* Test case for Bug#14233 produces the following warnings: */ |
| 185 | + ("Stored routine 'test'.'bug14233_1': invalid value in column mysql.proc"), |
| 186 | + ("Stored routine 'test'.'bug14233_2': invalid value in column mysql.proc"), |
| 187 | + ("Stored routine 'test'.'bug14233_3': invalid value in column mysql.proc"), |
| 188 | + |
| 189 | + /* |
| 190 | + BUG#32080 - Excessive warnings on Solaris: setrlimit could not |
| 191 | + change the size of core files |
| 192 | + */ |
| 193 | + ("setrlimit could not change the size of core files to 'infinity'"), |
| 194 | + |
| 195 | + /* |
| 196 | + rpl_extrColmaster_*.test, the slave thread produces warnings |
| 197 | + when it get updates to a table that has more columns on the |
| 198 | + master |
| 199 | + */ |
| 200 | + ("Slave: Unknown column 'c7' in 't15' Error_code: 1054"), |
| 201 | + ("Slave: Can't DROP 'c7'.* 1091"), |
| 202 | + ("Slave: Key column 'c6'.* 1072"), |
| 203 | + |
| 204 | + ("THE_LAST_SUPPRESSION")|| |
| 205 | + |
| 206 | + |
| 207 | +-- |
| 208 | +-- Procedure that uses the above created tables to check |
| 209 | +-- the servers error log for warnings |
| 210 | +-- |
| 211 | +CREATE DEFINER=root@localhost PROCEDURE check_warnings() |
| 212 | +BEGIN |
| 213 | + -- |
| 214 | + -- Load the server .err file into "error_log" table |
| 215 | + -- |
| 216 | + CREATE TEMPORARY TABLE error_log ( |
| 217 | + row INT AUTO_INCREMENT PRIMARY KEY, |
| 218 | + line mediumtext NULL |
| 219 | + ); |
| 220 | + |
| 221 | + SELECT variable_value INTO @log_error |
| 222 | + FROM information_schema.global_variables |
| 223 | + WHERE variable_name='LOG_ERROR'; |
| 224 | + |
| 225 | + SET @text= load_file(@log_error); |
| 226 | + -- select @text; |
| 227 | + |
| 228 | + WHILE LOCATE('\n', @text) DO |
| 229 | + INSERT error_log (line) |
| 230 | + VALUES ( |
| 231 | + SUBSTR(@text, 1, LOCATE('\n', @text)-1) |
| 232 | + ); |
| 233 | + SET @text= SUBSTR(@text FROM LOCATE('\n', @text)+1); |
| 234 | + END WHILE; |
| 235 | + |
| 236 | + -- select * from error_log; |
| 237 | + |
| 238 | + -- |
| 239 | + -- Remove all lines belonging to previous tests |
| 240 | + -- |
| 241 | + SELECT COALESCE(MAX(row),0) INTO @max_row |
| 242 | + FROM error_log |
| 243 | + WHERE line REGEXP "^CURRENT_TEST:"; |
| 244 | + DELETE FROM error_log WHERE row < @max_row; |
| 245 | + |
| 246 | + CREATE TEMPORARY TABLE suspect_lines AS |
| 247 | + SELECT DISTINCT el.line, 0 as "supressed" |
| 248 | + FROM error_log el, suspicious_patterns ep |
| 249 | + WHERE el.line REGEXP ep.pattern; |
| 250 | + |
| 251 | + -- Mark lines that are supressed by global supressions |
| 252 | + UPDATE suspect_lines sl, global_supressions gs |
| 253 | + SET supressed=1 |
| 254 | + WHERE sl.line REGEXP gs.pattern; |
| 255 | + |
| 256 | + -- Mark lines that are supressed by test specific supressions |
| 257 | + UPDATE suspect_lines sl, test_supressions ts |
| 258 | + SET supressed=2 |
| 259 | + WHERE sl.line REGEXP ts.pattern; |
| 260 | + |
| 261 | + SELECT COUNT(*) INTO @num_warnings FROM suspect_lines |
| 262 | + WHERE supressed=0; |
| 263 | + |
| 264 | + IF @num_warnings > 0 THEN |
| 265 | + SELECT @log_error; |
| 266 | + SELECT line as log_error |
| 267 | + FROM suspect_lines WHERE supressed=0; |
| 268 | + SELECT * FROM test_supressions; |
| 269 | + ELSE |
| 270 | + SELECT "OK"; |
| 271 | + END IF; |
| 272 | + |
| 273 | + -- Cleanup for next test |
| 274 | + TRUNCATE test_supressions; |
| 275 | + |
| 276 | +END|| |
| 277 | + |
| 278 | +-- |
| 279 | +-- Declare a procedure testcases can use to insert test |
| 280 | +-- specific supressions |
| 281 | +-- |
| 282 | +/*!50001 |
| 283 | +CREATE DEFINER=root@localhost |
| 284 | +PROCEDURE add_supression(pattern VARCHAR(255)) |
| 285 | +BEGIN |
| 286 | + INSERT INTO test_supressions (pattern) VALUES (pattern); |
| 287 | +END |
| 288 | +*/|| |
| 289 | + |
| 290 | + |
0 commit comments