mtr_warnings.sql 8.42 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
delimiter ||;

use mtr||

--
-- Load table with the patterns that are considered
-- as suspicious and should be examined further
--
CREATE TABLE suspicious_patterns (
  pattern VARCHAR(255)
)||


--
-- Declare a trigger that makes sure
-- no invalid patterns can be inserted
-- into suspicious_patterns
--
/*!50002
CREATE DEFINER=root@localhost TRIGGER sp_insert
BEFORE INSERT ON suspicious_patterns
FOR EACH ROW BEGIN
  DECLARE dummy INT;
  SELECT "" REGEXP NEW.pattern INTO dummy;
END
*/||


--
-- Insert patterns for the lines we should check
--
INSERT INTO suspicious_patterns VALUES
 ("^Warning:|mysqld: Warning|\\[Warning\\]"),
 ("^Error:|\\[ERROR\\]"),
 ("^==.* at 0x"),
 ("InnoDB: Warning"),
 ("^safe_mutex:|allocated at line"),
 ("missing DBUG_RETURN"),
 ("Attempting backtrace"),
 ("Assertion .* failed")||


--
-- Create table where testcases can insert patterns to
-- be supressed
--
CREATE TABLE test_supressions (
  pattern VARCHAR(255)
)||


--
-- Declare a trigger that makes sure
-- no invalid patterns can be inserted
-- into test_supressions
--
/*!50002
CREATE DEFINER=root@localhost TRIGGER ts_insert
BEFORE INSERT ON test_supressions
FOR EACH ROW BEGIN
  DECLARE dummy INT;
  SELECT "" REGEXP NEW.pattern INTO dummy;
END
*/||


--
-- Load table with patterns that will be supressed globally(always)
--
CREATE TABLE global_supressions (
  pattern VARCHAR(255)
)||


-- Declare a trigger that makes sure
-- no invalid patterns can be inserted
-- into global_supressions
--
/*!50002
CREATE DEFINER=root@localhost TRIGGER gs_insert
BEFORE INSERT ON global_supressions
FOR EACH ROW BEGIN
  DECLARE dummy INT;
  SELECT "" REGEXP NEW.pattern INTO dummy;
END
*/||



--
-- Insert patterns that should always be supressed
--
INSERT INTO global_supressions VALUES
 ("'SELECT UNIX_TIMESTAMP\\(\\)' failed on master"),
 ("Aborted connection"),
 ("Client requested master to start replication from impossible position"),
 ("Could not find first log file name in binary log"),
 ("Enabling keys got errno"),
 ("Error reading master configuration"),
 ("Error reading packet"),
 ("Event Scheduler"),
 ("Failed to open log"),
 ("Failed to open the existing master info file"),
 ("Forcing shutdown of [0-9]* plugins"),

 /*
   Due to timing issues, it might be that this warning
   is printed when the server shuts down and the
   computer is loaded.
 */

 ("Got error [0-9]* when reading table"),
 ("Incorrect definition of table"),
 ("Incorrect information in file"),
 ("InnoDB: Warning: we did not need to do crash recovery"),
 ("Invalid \\(old\\?\\) table or database name"),
 ("Lock wait timeout exceeded"),
 ("Log entry on master is longer than max_allowed_packet"),
 ("unknown option '--loose-"),
 ("unknown variable 'loose-"),
 ("You have forced lower_case_table_names to 0 through a command-line option"),
 ("Setting lower_case_table_names=2"),
 ("NDB Binlog:"),
 ("NDB: failed to setup table"),
 ("NDB: only row based binary logging"),
 ("Neither --relay-log nor --relay-log-index were used"),
 ("Query partially completed"),
 ("Slave I.O thread aborted while waiting for relay log"),
 ("Slave SQL thread is stopped because UNTIL condition"),
 ("Slave SQL thread retried transaction"),
 ("Slave \\(additional info\\)"),
 ("Slave: .*Duplicate column name"),
 ("Slave: .*master may suffer from"),
 ("Slave: According to the master's version"),
 ("Slave: Column [0-9]* type mismatch"),
 ("Slave: Error .* doesn't exist"),
 ("Slave: Error .*Unknown table"),
 ("Slave: Error in Write_rows event: "),
 ("Slave: Field .* of table .* has no default value"),
 ("Slave: Field .* doesn't have a default value"),
 ("Slave: Query caused different errors on master and slave"),
 ("Slave: Table .* doesn't exist"),
 ("Slave: Table width mismatch"),
 ("Slave: The incident LOST_EVENTS occured on the master"),
 ("Slave: Unknown error.* 1105"),
 ("Slave: Can't drop database.* database doesn't exist"),
 ("Slave SQL:.*(Error_code: \[\[:digit:\]\]+|Query:.*)"),
 ("Sort aborted"),
 ("Time-out in NDB"),
 ("Warning:\s+One can only use the --user.*root"),
 ("Warning:\s+Setting lower_case_table_names=2"),
 ("Warning:\s+Table:.* on (delete|rename)"),
 ("You have an error in your SQL syntax"),
 ("deprecated"),
 ("description of time zone"),
 ("equal MySQL server ids"),
 ("error .*connecting to master"),
 ("error reading log entry"),
 ("lower_case_table_names is set"),
 ("skip-name-resolve mode"),
 ("slave SQL thread aborted"),
 ("Slave: .*Duplicate entry"),

 /*
   Special case, made as specific as possible, for:
   Bug #28436: Incorrect position in SHOW BINLOG EVENTS causes
   server coredump
 */

 ("Error in Log_event::read_log_event\\\(\\\): 'Sanity check failed', data_len: 258, event_type: 49"),

 ("Statement is not safe to log in statement format"),

 /* test case for Bug#bug29807 copies a stray frm into database */
 ("InnoDB: Error: table `test`.`bug29807` does not exist in the InnoDB internal"),
 ("Cannot find or open table test\/bug29807 from"),

 /* innodb foreign key tests that fail in ALTER or RENAME produce this */
 ("InnoDB: Error: in ALTER TABLE `test`.`t[12]`"),
 ("InnoDB: Error: in RENAME TABLE table `test`.`t1`"),
 ("InnoDB: Error: table `test`.`t[12]` does not exist in the InnoDB internal"),

 /* Test case for Bug#14233 produces the following warnings: */
 ("Stored routine 'test'.'bug14233_1': invalid value in column mysql.proc"),
 ("Stored routine 'test'.'bug14233_2': invalid value in column mysql.proc"),
 ("Stored routine 'test'.'bug14233_3': invalid value in column mysql.proc"),

 /*
   BUG#32080 - Excessive warnings on Solaris: setrlimit could not
   change the size of core files
  */
 ("setrlimit could not change the size of core files to 'infinity'"),

 /*
   rpl_extrColmaster_*.test, the slave thread produces warnings
   when it get updates to a table that has more columns on the
   master
  */
 ("Slave: Unknown column 'c7' in 't15' Error_code: 1054"),
 ("Slave: Can't DROP 'c7'.* 1091"),
 ("Slave: Key column 'c6'.* 1072"),

203 204 205 206 207 208 209 210 211
 /* Test case for Bug#31590 in order_by.test produces the following error */
 ("Out of sort memory; increase server sort buffer size"),

 /* Special case for Bug #26402 in show_check.test
    - Question marks are not valid file name parts on Windows. Ignore
      this error message.
  */
 ("Can't find file: '.\\\\test\\\\\\?{8}.frm'"),

212 213 214 215 216 217 218
 ("THE_LAST_SUPPRESSION")||


--
-- Procedure that uses the above created tables to check
-- the servers error log for warnings
--
219
CREATE DEFINER=root@localhost PROCEDURE check_warnings(OUT result INT)
220
BEGIN
221 222 223

  -- Don't write these queries to binlog
  SET SQL_LOG_BIN=0;
224 225 226 227 228 229 230 231 232 233 234 235
  --
  -- Load the server .err file into "error_log" table
  --
  CREATE TEMPORARY TABLE error_log (
    row INT AUTO_INCREMENT PRIMARY KEY,
    line mediumtext NULL
  );

  SELECT variable_value INTO @log_error
    FROM information_schema.global_variables
      WHERE variable_name='LOG_ERROR';

236
  SET @@session.max_allowed_packet= 1024*1024*1024;
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279
  SET @text= load_file(@log_error);
  -- select @text;

  WHILE LOCATE('\n', @text) DO
    INSERT error_log (line)
      VALUES (
       SUBSTR(@text, 1, LOCATE('\n', @text)-1)
      );
    SET @text= SUBSTR(@text FROM LOCATE('\n', @text)+1);
  END WHILE;

  -- select * from error_log;

  --
  -- Remove all lines belonging to previous tests
  --
  SELECT COALESCE(MAX(row),0) INTO @max_row
    FROM error_log
      WHERE line REGEXP "^CURRENT_TEST:";
  DELETE FROM error_log WHERE row < @max_row;

  CREATE TEMPORARY TABLE suspect_lines AS
   SELECT DISTINCT el.line, 0 as "supressed"
     FROM error_log el, suspicious_patterns ep
       WHERE el.line REGEXP ep.pattern;

  -- Mark lines that are supressed by global supressions
  UPDATE suspect_lines sl, global_supressions gs
    SET supressed=1
      WHERE sl.line REGEXP gs.pattern;

  -- Mark lines that are supressed by test specific supressions
  UPDATE suspect_lines sl, test_supressions ts
    SET supressed=2
      WHERE sl.line REGEXP ts.pattern;

  SELECT COUNT(*) INTO @num_warnings FROM suspect_lines
    WHERE supressed=0;

  IF @num_warnings > 0 THEN
    SELECT @log_error;
    SELECT line as log_error
        FROM suspect_lines WHERE supressed=0;
280
    --SELECT * FROM test_supressions;
281 282
    -- Return 2 -> check failed
    SELECT 2 INTO result;
283
  ELSE
284 285
    -- Return 0 -> OK
    SELECT 0 INTO RESULT;
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305
  END IF;

  -- Cleanup for next test
  TRUNCATE test_supressions;

END||

--
-- Declare a procedure testcases can use to insert test
-- specific supressions
--
/*!50001
CREATE DEFINER=root@localhost
PROCEDURE add_supression(pattern VARCHAR(255))
BEGIN
  INSERT INTO test_supressions (pattern) VALUES (pattern);
END
*/||