Skip to content

Commit

Permalink
Bug#30508721: MTR DOESN'T KEEP TRACK OF THE STATE OF INNODB MONITORS
Browse files Browse the repository at this point in the history
Issue
-----
In case the state of an innodb monitor(enabled/disabled) is
changed during a test, it can affect other tests running after
it and lead to failures.

Fix
---
- Ensure that tests leave behind InnoDB monitors in their initial
  state (i.e., before the test run starts) by including the below
  entry in MTR check of test cases.
  SELECT name, status FROM INFORMATION_SCHEMA.INNODB_METRICS
  ORDER BY name;
- The patch also restores InnoDB metrics to their original state
  at the end of tests which modify them.

Change-Id: I116b7c3559ed2786fc24fed47305226d0a9e157c
RB: 23311
  • Loading branch information
Srikanth B R committed Nov 12, 2019
1 parent d23f396 commit abd33c2
Show file tree
Hide file tree
Showing 18 changed files with 123 additions and 81 deletions.
106 changes: 106 additions & 0 deletions mysql-test/include/innodb_monitor_restore.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
--disable_query_log

# MTR's check of test cases ensures that the state of innodb
# monitors(enabled/disabled) are not changed by tests.
# Some InnoDB monitors are enabled by default. In case some
# monitors are enabled during a test, there is no direct way
# to get back to the initial state of enabled monitors
# other than disabling them on a case-by-case basis.
#
# The purpose of this .inc file is to only retain those
# monitors which are enabled by default and disable the
# rest so that monitors changed in a test do not affect
# other tests.

SET GLOBAL innodb_monitor_disable=all;
SET GLOBAL innodb_monitor_enable="adaptive_hash_searches";
SET GLOBAL innodb_monitor_enable="adaptive_hash_searches_btree";
SET GLOBAL innodb_monitor_enable="buffer_data_reads";
SET GLOBAL innodb_monitor_enable="buffer_data_written";
SET GLOBAL innodb_monitor_enable="buffer_pages_created";
SET GLOBAL innodb_monitor_enable="buffer_pages_read";
SET GLOBAL innodb_monitor_enable="buffer_pages_written";
SET GLOBAL innodb_monitor_enable="buffer_pool_bytes_data";
SET GLOBAL innodb_monitor_enable="buffer_pool_bytes_dirty";
SET GLOBAL innodb_monitor_enable="buffer_pool_pages_data";
SET GLOBAL innodb_monitor_enable="buffer_pool_pages_dirty";
SET GLOBAL innodb_monitor_enable="buffer_pool_pages_free";
SET GLOBAL innodb_monitor_enable="buffer_pool_pages_misc";
SET GLOBAL innodb_monitor_enable="buffer_pool_pages_total";
SET GLOBAL innodb_monitor_enable="buffer_pool_reads";
SET GLOBAL innodb_monitor_enable="buffer_pool_read_ahead";
SET GLOBAL innodb_monitor_enable="buffer_pool_read_ahead_evicted";
SET GLOBAL innodb_monitor_enable="buffer_pool_read_requests";
SET GLOBAL innodb_monitor_enable="buffer_pool_size";
SET GLOBAL innodb_monitor_enable="buffer_pool_wait_free";
SET GLOBAL innodb_monitor_enable="buffer_pool_write_requests";
SET GLOBAL innodb_monitor_enable="dml_deletes";
SET GLOBAL innodb_monitor_enable="dml_inserts";
SET GLOBAL innodb_monitor_enable="dml_system_deletes";
SET GLOBAL innodb_monitor_enable="dml_system_inserts";
SET GLOBAL innodb_monitor_enable="dml_system_reads";
SET GLOBAL innodb_monitor_enable="dml_system_updates";
SET GLOBAL innodb_monitor_enable="dml_updates";
SET GLOBAL innodb_monitor_enable="file_num_open_files";
SET GLOBAL innodb_monitor_enable="ibuf_merges";
SET GLOBAL innodb_monitor_enable="ibuf_merges_delete";
SET GLOBAL innodb_monitor_enable="ibuf_merges_delete_mark";
SET GLOBAL innodb_monitor_enable="ibuf_merges_discard_delete";
SET GLOBAL innodb_monitor_enable="ibuf_merges_discard_delete_mark";
SET GLOBAL innodb_monitor_enable="ibuf_merges_discard_insert";
SET GLOBAL innodb_monitor_enable="ibuf_merges_insert";
SET GLOBAL innodb_monitor_enable="ibuf_size";
SET GLOBAL innodb_monitor_enable="innodb_activity_count";
SET GLOBAL innodb_monitor_enable="innodb_dblwr_pages_written";
SET GLOBAL innodb_monitor_enable="innodb_dblwr_writes";
SET GLOBAL innodb_monitor_enable="innodb_page_size";
SET GLOBAL innodb_monitor_enable="innodb_rwlock_sx_os_waits";
SET GLOBAL innodb_monitor_enable="innodb_rwlock_sx_spin_rounds";
SET GLOBAL innodb_monitor_enable="innodb_rwlock_sx_spin_waits";
SET GLOBAL innodb_monitor_enable="innodb_rwlock_s_os_waits";
SET GLOBAL innodb_monitor_enable="innodb_rwlock_s_spin_rounds";
SET GLOBAL innodb_monitor_enable="innodb_rwlock_s_spin_waits";
SET GLOBAL innodb_monitor_enable="innodb_rwlock_x_os_waits";
SET GLOBAL innodb_monitor_enable="innodb_rwlock_x_spin_rounds";
SET GLOBAL innodb_monitor_enable="innodb_rwlock_x_spin_waits";
SET GLOBAL innodb_monitor_enable="lock_deadlocks";
SET GLOBAL innodb_monitor_enable="lock_deadlock_false_positives";
SET GLOBAL innodb_monitor_enable="lock_deadlock_rounds";
SET GLOBAL innodb_monitor_enable="lock_row_lock_current_waits";
SET GLOBAL innodb_monitor_enable="lock_row_lock_time";
SET GLOBAL innodb_monitor_enable="lock_row_lock_time_avg";
SET GLOBAL innodb_monitor_enable="lock_row_lock_time_max";
SET GLOBAL innodb_monitor_enable="lock_row_lock_waits";
SET GLOBAL innodb_monitor_enable="lock_threads_waiting";
SET GLOBAL innodb_monitor_enable="lock_timeouts";
SET GLOBAL innodb_monitor_enable="log_waits";
SET GLOBAL innodb_monitor_enable="log_writes";
SET GLOBAL innodb_monitor_enable="log_write_requests";
SET GLOBAL innodb_monitor_enable="os_data_fsyncs";
SET GLOBAL innodb_monitor_enable="os_data_reads";
SET GLOBAL innodb_monitor_enable="os_data_writes";
SET GLOBAL innodb_monitor_enable="os_log_bytes_written";
SET GLOBAL innodb_monitor_enable="os_log_fsyncs";
SET GLOBAL innodb_monitor_enable="os_log_pending_fsyncs";
SET GLOBAL innodb_monitor_enable="os_log_pending_writes";
SET GLOBAL innodb_monitor_enable="trx_rseg_history_len";

# NOTE:
# The default value for below variables is an empty string
# it assigning an empty string using the SET statement results
# in an error. The only way we can restore the value of the
# variable and avoid check_testcase failures is by trying to
# set the variable to its default value. Even though the
# variable has no default value, the value gets reset to an
# empty string and throws the below warning:
# Warning NNNN Default value is not defined for this set option.
# Please specify correct counter or module name.

--disable_warnings ER_NO_DEFAULT
SET GLOBAL innodb_monitor_enable=default;
SET GLOBAL innodb_monitor_disable=default;
SET GLOBAL innodb_monitor_reset=default;
SET GLOBAL innodb_monitor_reset_all=default;
--enable_warnings ER_NO_DEFAULT

--enable_query_log
8 changes: 8 additions & 0 deletions mysql-test/include/mtr_check.sql
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ BEGIN

-- Dump all events, there should be none
SELECT * FROM INFORMATION_SCHEMA.EVENTS;

-- Dump all triggers except mtr internals, only those in the sys schema should exist
-- do not select the CREATED column however, as tests like mysqldump.test / mysql_ugprade.test update this
SELECT TRIGGER_CATALOG, TRIGGER_SCHEMA, TRIGGER_NAME, EVENT_MANIPULATION,
Expand All @@ -125,6 +126,7 @@ BEGIN
FROM INFORMATION_SCHEMA.TRIGGERS
WHERE TRIGGER_NAME NOT IN ('gs_insert', 'ts_insert')
ORDER BY TRIGGER_CATALOG, TRIGGER_SCHEMA, TRIGGER_NAME;

-- Dump all created procedures, only those in the sys schema should exist
-- do not select the CREATED or LAST_ALTERED columns however, as tests like mysqldump.test / mysql_ugprade.test update this
SELECT SPECIFIC_NAME,ROUTINE_CATALOG,ROUTINE_SCHEMA,ROUTINE_NAME,ROUTINE_TYPE,DATA_TYPE,CHARACTER_MAXIMUM_LENGTH,
Expand All @@ -133,13 +135,19 @@ BEGIN
IS_DETERMINISTIC,SQL_DATA_ACCESS,SQL_PATH,SECURITY_TYPE,SQL_MODE,ROUTINE_COMMENT,DEFINER,
CHARACTER_SET_CLIENT,COLLATION_CONNECTION,DATABASE_COLLATION
FROM INFORMATION_SCHEMA.ROUTINES ORDER BY ROUTINE_SCHEMA, ROUTINE_NAME, ROUTINE_TYPE;

-- Dump all views, only those in the sys schema should exist
SELECT * FROM INFORMATION_SCHEMA.VIEWS
ORDER BY TABLE_SCHEMA, TABLE_NAME;

-- Dump all plugins, loaded with plugin-loading options or through
-- INSTALL/UNINSTALL command
SELECT * FROM INFORMATION_SCHEMA.PLUGINS;

-- Leave InnoDB metrics in the same state
SELECT name, status FROM INFORMATION_SCHEMA.INNODB_METRICS
ORDER BY name;

SHOW GLOBAL STATUS LIKE 'slave_open_temp_tables';

-- Check for number of active connections before & after the test run.
Expand Down
3 changes: 0 additions & 3 deletions mysql-test/suite/innodb/r/innodb_idle_flush_pct.result
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,4 @@ SELECT COUNT>0 FROM INFORMATION_SCHEMA.INNODB_METRICS
WHERE NAME='buffer_flush_background_total_pages';
COUNT>0
0
SET GLOBAL innodb_monitor_disable = default;
SET GLOBAL innodb_monitor_enable = default;
SET GLOBAL innodb_monitor_reset_all = default;
DROP TABLE t1;
3 changes: 0 additions & 3 deletions mysql-test/suite/innodb/r/monitor.result
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,4 @@ SELECT NAME, COUNT FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME
LIKE 'buffer_page_written_index_leaf';
NAME COUNT
buffer_page_written_index_leaf NNNN
SET GLOBAL innodb_monitor_enable=default;
SET GLOBAL innodb_monitor_disable=default;
SET GLOBAL innodb_monitor_reset_all=default;
DROP TABLE t1;
6 changes: 1 addition & 5 deletions mysql-test/suite/innodb/t/innodb_idle_flush_pct.test
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,5 @@ SET GLOBAL innodb_monitor_disable = all;
SET GLOBAL innodb_monitor_reset_all = all;
SELECT COUNT>0 FROM INFORMATION_SCHEMA.INNODB_METRICS
WHERE NAME='buffer_flush_background_total_pages';
--disable_warnings
SET GLOBAL innodb_monitor_disable = default;
SET GLOBAL innodb_monitor_enable = default;
SET GLOBAL innodb_monitor_reset_all = default;
--enable_warnings
DROP TABLE t1;
--source include/innodb_monitor_restore.inc
7 changes: 1 addition & 6 deletions mysql-test/suite/innodb/t/monitor.test
Original file line number Diff line number Diff line change
Expand Up @@ -437,10 +437,5 @@ UNLOCK TABLES;
SELECT NAME, COUNT FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME
LIKE 'buffer_page_written_index_leaf';

--disable_warnings
SET GLOBAL innodb_monitor_enable=default;
SET GLOBAL innodb_monitor_disable=default;
SET GLOBAL innodb_monitor_reset_all=default;
--enable_warnings

DROP TABLE t1;
--source include/innodb_monitor_restore.inc
Original file line number Diff line number Diff line change
Expand Up @@ -563,8 +563,4 @@ unlink: t1.cfg
DROP DATABASE test_wl5522;
set global innodb_monitor_disable = all;
set global innodb_monitor_reset_all = all;
set global innodb_monitor_enable = default;
set global innodb_monitor_disable = default;
set global innodb_monitor_reset = default;
set global innodb_monitor_reset_all = default;
SET GLOBAL INNODB_FILE_PER_TABLE=1;
Original file line number Diff line number Diff line change
Expand Up @@ -705,13 +705,6 @@ DROP DATABASE test_wl5522;
set global innodb_monitor_disable = all;
set global innodb_monitor_reset_all = all;

-- disable_warnings
set global innodb_monitor_enable = default;
set global innodb_monitor_disable = default;
set global innodb_monitor_reset = default;
set global innodb_monitor_reset_all = default;
-- enable_warnings

--disable_query_log
call mtr.add_suppression("\\[ERROR\\] .*MY-\\d+.* Cannot open datafile for read-only:");
call mtr.add_suppression("\\[ERROR\\] .*MY-\\d+.* Could not find a valid tablespace file for");
Expand All @@ -735,3 +728,4 @@ call mtr.add_suppression("\\[ERROR\\] .*MY-\\d+.* The error means that another p
--remove_file $MYSQLTEST_VARDIR/tmp/t1.ibd

eval SET GLOBAL INNODB_FILE_PER_TABLE=$innodb_file_per_table;
--source include/innodb_monitor_restore.inc
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,3 @@ icp_match 1
drop table monitor_test;
set global innodb_monitor_disable = All;
set global innodb_monitor_reset_all = all;
set global innodb_monitor_enable = default;
set global innodb_monitor_disable = default;
set global innodb_monitor_reset = default;
set global innodb_monitor_reset_all = default;
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,3 @@ icp_match 1
drop table monitor_test;
set global innodb_monitor_disable = All;
set global innodb_monitor_reset_all = all;
set global innodb_monitor_enable = default;
set global innodb_monitor_disable = default;
set global innodb_monitor_reset = default;
set global innodb_monitor_reset_all = default;
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,3 @@ icp_match 1
drop table monitor_test;
set global innodb_monitor_disable = All;
set global innodb_monitor_reset_all = all;
set global innodb_monitor_enable = default;
set global innodb_monitor_disable = default;
set global innodb_monitor_reset = default;
set global innodb_monitor_reset_all = default;
4 changes: 0 additions & 4 deletions mysql-test/suite/sys_vars/r/innodb_monitor_reset_basic.result
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,3 @@ set global innodb_monitor_reset =0xe9;
ERROR 42000: Variable 'innodb_monitor_reset' can't be set to the value of '\xE9'
set global innodb_monitor_disable =0xed;
ERROR 42000: Variable 'innodb_monitor_disable' can't be set to the value of '\xED'
set global innodb_monitor_enable = default;
set global innodb_monitor_disable = default;
set global innodb_monitor_reset = default;
set global innodb_monitor_reset_all = default;
Original file line number Diff line number Diff line change
Expand Up @@ -376,9 +376,4 @@ drop table monitor_test;
set global innodb_monitor_disable = All;
set global innodb_monitor_reset_all = all;

-- disable_warnings
set global innodb_monitor_enable = default;
set global innodb_monitor_disable = default;
set global innodb_monitor_reset = default;
set global innodb_monitor_reset_all = default;
-- enable_warnings
--source include/innodb_monitor_restore.inc
8 changes: 1 addition & 7 deletions mysql-test/suite/sys_vars/t/innodb_monitor_enable_basic.test
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# This is the test for Metrics Monitor Table feature.
# Test the metrics monitor system's control system
# and counter accuracy.

set global innodb_monitor_disable = All;
# Test turn on/off the monitor counter with "all" option
# By default, they will be off
Expand Down Expand Up @@ -376,9 +375,4 @@ drop table monitor_test;
set global innodb_monitor_disable = All;
set global innodb_monitor_reset_all = all;

-- disable_warnings
set global innodb_monitor_enable = default;
set global innodb_monitor_disable = default;
set global innodb_monitor_reset = default;
set global innodb_monitor_reset_all = default;
-- enable_warnings
--source include/innodb_monitor_restore.inc
Original file line number Diff line number Diff line change
Expand Up @@ -376,9 +376,4 @@ drop table monitor_test;
set global innodb_monitor_disable = All;
set global innodb_monitor_reset_all = all;

-- disable_warnings
set global innodb_monitor_enable = default;
set global innodb_monitor_disable = default;
set global innodb_monitor_reset = default;
set global innodb_monitor_reset_all = default;
-- enable_warnings
--source include/innodb_monitor_restore.inc
7 changes: 1 addition & 6 deletions mysql-test/suite/sys_vars/t/innodb_monitor_reset_basic.test
Original file line number Diff line number Diff line change
Expand Up @@ -386,9 +386,4 @@ set global innodb_monitor_reset =0xe9;
--error ER_WRONG_VALUE_FOR_VAR
set global innodb_monitor_disable =0xed;

-- disable_warnings
set global innodb_monitor_enable = default;
set global innodb_monitor_disable = default;
set global innodb_monitor_reset = default;
set global innodb_monitor_reset_all = default;
-- enable_warnings
--source include/innodb_monitor_restore.inc
7 changes: 1 addition & 6 deletions mysql-test/suite/sys_vars/t/innodb_purge_run_now_basic.test
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,4 @@ SELECT name, count
set global innodb_monitor_disable = all;
set global innodb_monitor_reset_all = all;

-- disable_warnings
set global innodb_monitor_enable = default;
set global innodb_monitor_disable = default;
set global innodb_monitor_reset = default;
set global innodb_monitor_reset_all = default;
-- enable_warnings
--source include/innodb_monitor_restore.inc
7 changes: 1 addition & 6 deletions mysql-test/suite/sys_vars/t/innodb_purge_stop_now_basic.test
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,4 @@ SELECT name, count
set global innodb_monitor_disable = all;
set global innodb_monitor_reset_all = all;

-- disable_warnings
set global innodb_monitor_enable = default;
set global innodb_monitor_disable = default;
set global innodb_monitor_reset = default;
set global innodb_monitor_reset_all = default;
-- enable_warnings
--source include/innodb_monitor_restore.inc

0 comments on commit abd33c2

Please sign in to comment.