Skip to content

Commit

Permalink
MDEV-33501 Extend query_response_time plugin to be compatible with Pe…
Browse files Browse the repository at this point in the history
…rcona server

This is to update the plugin to be compatible with Percona's
query_response_time plugin, with some additions.
Some of the tests are taken from Percona server.

- Added plugins QUERY_RESPONSE_TIME_READ, QUERY_RESPONSE_TIME_WRITE and
  QUERY_RESPONSE_TIME_READ_WRITE.
- Added option query_response_time_session_stats, with possible values
  GLOBAL, ON or OFF, to the query_response_time plugin.

Notes:
- All modules are dependent on QUERY_RESPONSE_READ_TIME. This must always
  be enabled if any of the other modules are used.
  This will be auto-enabled in the near future.
- Accounting are done per statement. Stored functions are regarded
  as part of the original statement.
- For stored procedures the accounting are done per statement executed
  in the stored procedure. CALL will not be accounted because of this.
- FLUSH commands will not be accounted for. This is to ensure that
  FLUSH QUERY_RESPONSE_TIME is not part of the statistics.
  (This helps when testing with mtr and otherwise).
- FLUSH QUERY_RESPONSE_TIME_READ and FLUSH QUERY_RESPONSE_TIME_READ
  only resets the corresponding status.
- FLUSH QUERY_RESPONSE_TIME and FLUSH QUERY_RESPONSE_TIME_READ_WRITE or
  changing the value of query_response_time_range_base followed by
  any FLUSH of QUERY_RESPOSNSE_TIME resets all status.
  • Loading branch information
montywi authored and vuvova committed May 27, 2024
1 parent 5296f90 commit 243b9f3
Show file tree
Hide file tree
Showing 27 changed files with 2,093 additions and 449 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ SHOW VARIABLES WHERE VARIABLE_NAME LIKE 'query_response_time%' AND VARIABLE_NAME
Variable_name Value
query_response_time_flush OFF
query_response_time_range_base 10
query_response_time_session_stats GLOBAL
query_response_time_stats OFF
SHOW CREATE TABLE INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
Table Create Table
Expand All @@ -18,6 +19,27 @@ PLUGIN_AUTHOR Percona and Sergey Vojtovich
PLUGIN_DESCRIPTION Query Response Time Distribution INFORMATION_SCHEMA Plugin
PLUGIN_LICENSE GPL
PLUGIN_MATURITY Stable
PLUGIN_NAME QUERY_RESPONSE_TIME_READ
PLUGIN_VERSION 1.0
PLUGIN_TYPE INFORMATION SCHEMA
PLUGIN_AUTHOR Percona and Sergey Vojtovich
PLUGIN_DESCRIPTION Query Response Time Distribution INFORMATION_SCHEMA Plugin
PLUGIN_LICENSE GPL
PLUGIN_MATURITY Stable
PLUGIN_NAME QUERY_RESPONSE_TIME_WRITE
PLUGIN_VERSION 1.0
PLUGIN_TYPE INFORMATION SCHEMA
PLUGIN_AUTHOR Percona and Sergey Vojtovich
PLUGIN_DESCRIPTION Query Response Time Distribution INFORMATION_SCHEMA Plugin
PLUGIN_LICENSE GPL
PLUGIN_MATURITY Stable
PLUGIN_NAME QUERY_RESPONSE_TIME_READ_WRITE
PLUGIN_VERSION 1.0
PLUGIN_TYPE INFORMATION SCHEMA
PLUGIN_AUTHOR Monty
PLUGIN_DESCRIPTION Query Response Time Distribution INFORMATION_SCHEMA Plugin
PLUGIN_LICENSE GPL
PLUGIN_MATURITY Stable
PLUGIN_NAME QUERY_RESPONSE_TIME_AUDIT
PLUGIN_VERSION 1.0
PLUGIN_TYPE AUDIT
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME WHERE count != 0;
SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME_READ WHERE count != 0;
SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME_WRITE WHERE count != 0;

--disable_query_log

--let $assert_text= The sum of query counts in read and write tables must be equal to query count of the common table
SELECT SUM(COUNT) INTO @common_count FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
SELECT SUM(COUNT) INTO @ro_count FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME_READ;
SELECT SUM(COUNT) INTO @rw_count FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME_WRITE;
--let $assert_cond= @common_count = @ro_count + @rw_count;
--source include/assert.inc

#
# Bug 1552428: table contents should not depend on the table case name
#
--let $assert_text= QUERY_RESPONSE_TIME query counts must be equal regardless of the table name case
SELECT SUM(COUNT) INTO @common_count_lc FROM information_schema.query_response_time;
--let $assert_cond= @common_count = @common_count_lc
--source include/assert.inc

--let $assert_text= QUERY_RESPONSE_TIME_READ query counts must be equal regardless of the table name case
SELECT SUM(COUNT) INTO @ro_count_lc FROM information_schema.query_response_time_read;
--let $assert_cond= @ro_count = @ro_count_lc
--source include/assert.inc

--let $assert_text= QUERY_RESPONSE_TIME_WRITE query counts must be equal regardless of the table name case
SELECT SUM(COUNT) INTO @rw_count_lc FROM information_schema.query_response_time_write;
--let $assert_cond= @rw_count = @rw_count_lc
--source include/assert.inc

--enable_query_log
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--disable_query_log
--disable_result_log
SET GLOBAL QUERY_RESPONSE_TIME_STATS = 0;
SET SESSION QUERY_RESPONSE_TIME_EXEC_TIME_DEBUG = 500000;
FLUSH QUERY_RESPONSE_TIME;
--enable_query_log
--enable_result_log
--source query_response_time-check.inc
--disable_query_log
--disable_result_log
SET GLOBAL QUERY_RESPONSE_TIME_STATS = 1;
FLUSH QUERY_RESPONSE_TIME;
--enable_query_log
--enable_result_log
--echo ------------------Test body begin--------------------
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
--echo ------------------Test body end----------------------
--disable_query_log
SET GLOBAL QUERY_RESPONSE_TIME_STATS = 0;
SET SESSION QUERY_RESPONSE_TIME_EXEC_TIME_DEBUG = DEFAULT;
--enable_query_log
--source query_response_time-check.inc
Loading

0 comments on commit 243b9f3

Please sign in to comment.