Commit ee156bf0 authored by Magnus Svensson's avatar Magnus Svensson

WL#4189 mtr.pl v2

 - rewrite "check warnings" to be faster by not creating a full join
   between error_log and suspicious_patterns while running REGEXP.
   Instead add a column to error_log that will be set to 1 to indicate
   a warning and run the 6 REGEXP's we have for suspicious lines as
   6 separate full table scans.
 - Remove the "suspicious_patterns" table from mtr db
 - Use 'xykls37' as separator when loading the error log, that line should
   hopefully never exist in a line that should be a warning
parent 3bec589b
......@@ -5,6 +5,9 @@
#
--disable_query_log
# Don't write these queries to binlog
set SQL_LOG_BIN=0;
# Turn off any debug crashes, allow the variable to be
# non existent in release builds
--error 0,1193
......@@ -14,8 +17,9 @@ use mtr;
create temporary table error_log (
row int auto_increment primary key,
suspicious int default 0,
file_name varchar(255),
line varchar(1024) null
line varchar(1024) default null
) engine=myisam;
# Get the name of servers error log
......@@ -23,7 +27,8 @@ let $log_error= query_get_value(show variables like 'log_error', Value, 1);
# Try to load the error log into the temporary table
--error 0,1085
eval load data infile '$log_error' into table error_log (line)
eval load data infile '$log_error' into table error_log
fields terminated by 'xykls37' (line)
set file_name='$log_error';
if ($mysql_errno)
{
......@@ -33,7 +38,8 @@ if ($mysql_errno)
# a new error log file that is not world readable.
# chmod the error log file and try to open it again
chmod 0644 $log_error;
eval load data infile '$log_error' into table error_log (line)
eval load data infile '$log_error' into table error_log
fields terminated by 'xykls37' (line)
set file_name='$log_error';
# Also load the .err-old file where there might be
......@@ -42,7 +48,8 @@ if ($mysql_errno)
# Disabled intil Bug#42320 has been fixed
#let $old_log_error = $log_error-old;
#chmod 0644 $old_log_error;
#eval load data infile '$old_log_error' into table error_log (line)
#eval load data infile '$old_log_error' into table error_log
# fields terminated by 'xykls37' (line)
# set file_name='$old_log_error';
}
......
......@@ -2,44 +2,6 @@ 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)
) ENGINE=MyISAM||
--
-- 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 suppressed
......@@ -232,27 +194,57 @@ BEGIN
WHERE line REGEXP "^CURRENT_TEST:";
DELETE FROM error_log WHERE row < @max_row;
CREATE TEMPORARY TABLE suspect_lines ENGINE=MyISAM AS
SELECT DISTINCT el.file_name, el.line, 0 as "suppressed"
FROM error_log el, suspicious_patterns ep
WHERE el.line REGEXP ep.pattern;
--
-- Mark all lines with certain patterns as suspicious
--
UPDATE error_log SET suspicious= 1
WHERE suspicious=0
AND line REGEXP "^Warning:|mysqld: Warning|\\[Warning\\]";
UPDATE error_log SET suspicious= 1
WHERE suspicious=0
AND line REGEXP "^Error:|\\[ERROR\\]";
UPDATE error_log SET suspicious= 1
WHERE suspicious=0
AND line REGEXP "^==.* at 0x";
UPDATE error_log SET suspicious= 1
WHERE suspicious=0
AND line REGEXP "InnoDB: Warning";
UPDATE error_log SET suspicious= 1
WHERE suspicious=0
AND line REGEXP "^safe_mutex:|allocated at line";
UPDATE error_log SET suspicious= 1
WHERE suspicious=0
AND line REGEXP "missing DBUG_RETURN";
UPDATE error_log SET suspicious= 1
WHERE suspicious=0
AND line REGEXP "Attempting backtrace";
UPDATE error_log SET suspicious= 1
WHERE suspicious=0
AND line REGEXP "Assertion .* failed";
-- Mark lines that are suppressed by global suppressions
UPDATE suspect_lines sl, global_suppressions gs
SET suppressed=1
WHERE sl.line REGEXP gs.pattern;
--
-- Remove mark from lines that are suppressed by global suppressions
--
UPDATE error_log el, global_suppressions gs
SET suspicious=0
WHERE el.suspicious=1 AND el.line REGEXP gs.pattern;
-- Mark lines that are suppressed by test specific suppressions
UPDATE suspect_lines sl, test_suppressions ts
SET suppressed=2
WHERE sl.line REGEXP ts.pattern;
--
-- Remove mark from lines that are suppressed by test specific suppressions
--
UPDATE error_log el, test_suppressions ts
SET suspicious=0
WHERE el.suspicious=1 AND el.line REGEXP ts.pattern;
SELECT COUNT(*) INTO @num_warnings FROM suspect_lines
WHERE suppressed=0;
--
-- Get the number of marked lines and return result
--
SELECT COUNT(*) INTO @num_warnings FROM error_log
WHERE suspicious=1;
IF @num_warnings > 0 THEN
SELECT file_name, line as log_error
FROM suspect_lines WHERE suppressed=0;
SELECT file_name, line
FROM error_log WHERE suspicious=1;
--SELECT * FROM test_suppressions;
-- Return 2 -> check failed
SELECT 2 INTO result;
......@@ -263,7 +255,7 @@ BEGIN
-- Cleanup for next test
TRUNCATE test_suppressions;
DROP TABLE error_log, suspect_lines;
DROP TABLE error_log;
END||
......
Run mysql_upgrade once
mtr.global_suppressions OK
mtr.suspicious_patterns OK
mtr.test_suppressions OK
mysql.columns_priv OK
mysql.db OK
......@@ -33,7 +32,6 @@ Run it again - should say already completed
This installation of MySQL is already upgraded to VERSION, use --force if you still need to run mysql_upgrade
Force should run it regardless of wether it's been run before
mtr.global_suppressions OK
mtr.suspicious_patterns OK
mtr.test_suppressions OK
mysql.columns_priv OK
mysql.db OK
......@@ -66,7 +64,6 @@ CREATE USER mysqltest1@'%' IDENTIFIED by 'sakila';
GRANT ALL ON *.* TO mysqltest1@'%';
Run mysql_upgrade with password protected account
mtr.global_suppressions OK
mtr.suspicious_patterns OK
mtr.test_suppressions OK
mysql.columns_priv OK
mysql.db OK
......@@ -101,7 +98,6 @@ mysqlcheck: Got error: 2005: Unknown MySQL server host 'not_existing_host' (errn
FATAL ERROR: Upgrade failed
set GLOBAL sql_mode='STRICT_ALL_TABLES,ANSI_QUOTES,NO_ZERO_DATE';
mtr.global_suppressions OK
mtr.suspicious_patterns OK
mtr.test_suppressions OK
mysql.columns_priv OK
mysql.db OK
......
......@@ -2,7 +2,6 @@ DROP TABLE IF EXISTS t1, `t``1`, `t 1`;
drop view if exists v1;
drop database if exists client_test_db;
mtr.global_suppressions OK
mtr.suspicious_patterns OK
mtr.test_suppressions OK
mysql.columns_priv OK
mysql.db OK
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment