mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Remove one of the major sources of race condiitons in mariadb-test. Normally, mariadb_close() sends COM_QUIT to the server and immediately disconnects. In mariadb-test it means the test can switch to another connection and sends queries to the server before the server even started parsing the COM_QUIT packet and these queries can see the connection as fully active, as it didn't reach dispatch_command yet. This is a major source of instability in tests and many - but not all, still less than a half - tests employ workarounds. The correct one is a pair count_sessions.inc/wait_until_count_sessions.inc. Also very popular was wait_until_disconnected.inc, which was completely useless, because it verifies that the connection is closed, and after disconnect it always is, it didn't verify whether the server processed COM_QUIT. Sadly the placebo was as widely used as the real thing. Let's fix this by making mariadb-test `disconnect` command _to wait_ for the server to confirm. This makes almost all workarounds redundant. In some cases count_sessions.inc/wait_until_count_sessions.inc is still needed, though, as only `disconnect` command is changed: * after external tools, like `exec $MYSQL` * after failed `connect` command * replication, after `STOP SLAVE` * Federated/CONNECT/SPIDER/etc after `DROP TABLE` and also in some XA tests, because an XA transaction is dissociated from the THD very late, after the server has closed the client connection. Collateral cleanups: fix comments, remove some redundant statements: * DROP IF EXISTS if nothing is known to exist * DROP table/view before DROP DATABASE * REVOKE privileges before DROP USER etc
295 lines
13 KiB
Plaintext
295 lines
13 KiB
Plaintext
################# suite/perfschema/t/show_plugin.test ##########################
|
|
# #
|
|
# MySQL plugins can define their own status variables and system variables. #
|
|
# This test exercises SHOW STATUS, SHOW VARIABLES and the status and system #
|
|
# variable tables while the EXAMPLE plugin is loaded and unloaded. #
|
|
# #
|
|
# The EXAMPLE plugin defines the following system and status variables: #
|
|
# Global system variables: #
|
|
# example_double_thdvar #
|
|
# example_double_var #
|
|
# example_enum_var #
|
|
# example_ulong_var #
|
|
# #
|
|
# Session variables: #
|
|
# example_double_thdvar - Local and/or global #
|
|
# #
|
|
# Global status: #
|
|
# example_func_example - Status function #
|
|
# #
|
|
################################################################################
|
|
|
|
--source include/have_perfschema.inc
|
|
--source include/not_embedded.inc
|
|
--source include/not_windows_embedded.inc
|
|
--source include/have_example_plugin.inc
|
|
--source include/have_innodb.inc
|
|
--source include/have_debug_sync.inc
|
|
|
|
--echo #
|
|
--echo # ================================================================================
|
|
--echo # SETUP
|
|
--echo # ================================================================================
|
|
--echo #
|
|
--echo # Verify EXAMPLE plugin is not loaded
|
|
SELECT COUNT(*) = 0 AS "Expect 1" FROM information_schema.plugins WHERE plugin_name = "EXAMPLE";
|
|
--echo #
|
|
--echo # Create one session to force local and global system variables
|
|
--connect(con0, localhost, root,,)
|
|
--connection default
|
|
--echo #
|
|
--echo # ================================================================================
|
|
--echo # TEST 1- NO PLUGIN VARS
|
|
--echo # ================================================================================
|
|
--source ../include/show_plugin_verifier.inc
|
|
--echo #
|
|
|
|
--echo # ================================================================================
|
|
--echo # TEST 2 - PLUGIN LOAD, UNLOAD, RELOAD
|
|
--echo # ================================================================================
|
|
--echo # ================================================================================
|
|
--echo # 2.1 - INSTALL PLUGIN
|
|
--echo # ================================================================================
|
|
INSTALL PLUGIN example SONAME 'ha_example';
|
|
|
|
--echo #
|
|
--echo # ================================================================================
|
|
--echo # 2.1a - FORCE SYNC OF LOCAL AND GLOBAL SYSTEM VARS
|
|
--echo # ================================================================================
|
|
--source ../include/show_plugin_verifier.inc
|
|
|
|
--disconnect con0
|
|
|
|
--echo #
|
|
--echo # ================================================================================
|
|
--echo # 2.2 - SET PLUGIN VARS
|
|
--echo # ================================================================================
|
|
--echo # GLOBAL
|
|
SET GLOBAL example_ulong_var = 100;
|
|
SET GLOBAL example_enum_var = e1;
|
|
SET GLOBAL example_double_var = 100.9990;
|
|
SET GLOBAL example_double_thdvar = 101.9991;
|
|
--echo # SESSION
|
|
SET SESSION example_double_thdvar = 102.9992;
|
|
|
|
--echo #
|
|
--echo # ================================================================================
|
|
--echo # 2.3 - VERIFY UPDATED PLUGIN VARS
|
|
--echo # ================================================================================
|
|
--source ../include/show_plugin_verifier.inc
|
|
|
|
--echo #
|
|
--echo # ================================================================================
|
|
--echo # 2.4 - UNINSTALL PLUGIN
|
|
--echo # ================================================================================
|
|
UNINSTALL PLUGIN example;
|
|
|
|
--echo #
|
|
--echo # ================================================================================
|
|
--echo # 2.5 - VERIFY NO PLUGIN VARS
|
|
--echo # ================================================================================
|
|
--source ../include/show_plugin_verifier.inc
|
|
|
|
--echo #
|
|
--echo # ================================================================================
|
|
--echo # 2.6 - REINSTALL PLUGIN
|
|
--echo # ================================================================================
|
|
--echo # Reinstall EXAMPLE plugin
|
|
INSTALL PLUGIN example SONAME 'ha_example';
|
|
|
|
--echo #
|
|
--echo # ================================================================================
|
|
--echo # 2.7 - SET PLUGIN VARS AGAIN
|
|
--echo # ================================================================================
|
|
--echo # GLOBAL
|
|
SET GLOBAL example_ulong_var = 200;
|
|
SET GLOBAL example_enum_var = e2;
|
|
SET GLOBAL example_double_var = 200.8880;
|
|
SET GLOBAL example_double_thdvar = 201.8881;
|
|
--echo # SESSION
|
|
SET SESSION example_double_thdvar = 202.8882;
|
|
|
|
--echo #
|
|
--echo # ================================================================================
|
|
--echo # 2.8 - VERIFY PLUGIN VARS
|
|
--echo # ================================================================================
|
|
--source ../include/show_plugin_verifier.inc
|
|
|
|
--echo #
|
|
--echo # ================================================================================
|
|
--echo # 2.9 - UNINSTALL PLUGIN
|
|
--echo # ================================================================================
|
|
UNINSTALL PLUGIN example;
|
|
|
|
--echo #
|
|
--echo # ================================================================================
|
|
--echo # 2.10 - VERIFY NO PLUGIN VARS
|
|
--echo # ================================================================================
|
|
--source ../include/show_plugin_verifier.inc
|
|
|
|
--echo #
|
|
--echo # ================================================================================
|
|
--echo # TEST 3 - SESSION PLUGIN VARS ON MULTIPLE CONNECTIONS
|
|
--echo # ================================================================================
|
|
--echo #
|
|
--echo # ================================================================================
|
|
--echo # 3.1 - INSTALL PLUGIN
|
|
--echo # ================================================================================
|
|
INSTALL PLUGIN example SONAME 'ha_example';
|
|
|
|
--echo #
|
|
--echo # ================================================================================
|
|
--echo # 3.2 - SET GLOBAL AND DEFAULT CONNECTION VARS
|
|
--echo # ================================================================================
|
|
--connection default
|
|
SET GLOBAL example_ulong_var = 300;
|
|
SET GLOBAL example_enum_var = e1;
|
|
SET GLOBAL example_double_var = 301.0000;
|
|
SET GLOBAL example_double_thdvar = 302.0000;
|
|
SET SESSION example_double_thdvar = 300.0000;
|
|
|
|
--echo #
|
|
--echo # ================================================================================
|
|
--echo # 3.3 - CONNECT 3 CLIENTS, SET LOCAL PLUGIN VARS
|
|
--echo # ================================================================================
|
|
--connect(con1, localhost, root,,)
|
|
SET SESSION example_double_thdvar = 300.1111;
|
|
--echo #
|
|
--connect(con2, localhost, root,,)
|
|
SET SESSION example_double_thdvar = 300.2222;
|
|
--echo #
|
|
--connect(con3, localhost, root,,)
|
|
SET SESSION example_double_thdvar = 300.3333;
|
|
--echo #
|
|
--connection default
|
|
|
|
--echo #
|
|
--echo # ================================================================================
|
|
--echo # 3.4 - VERIFY GLOBAL AND SESSION PLUGIN VARS
|
|
--echo # ================================================================================
|
|
--source ../include/show_plugin_verifier.inc
|
|
--echo #
|
|
--echo # Variables by thread
|
|
SELECT variable_name, variable_value FROM performance_schema.variables_by_thread
|
|
WHERE variable_name LIKE "example_%" ORDER BY variable_value;
|
|
|
|
--echo #
|
|
--echo # ================================================================================
|
|
--echo # 3.5 - DISCONNECT CLIENTS
|
|
--echo # ================================================================================
|
|
--disconnect con1
|
|
--disconnect con2
|
|
--disconnect con3
|
|
--connection default
|
|
|
|
--echo #
|
|
--echo # ================================================================================
|
|
--echo # 3.6 - VERIFY SESSION VARS ARE REMOVED
|
|
--echo # ================================================================================
|
|
--source ../include/show_plugin_verifier.inc
|
|
--echo #
|
|
--echo # Variables by thread
|
|
SELECT variable_name, variable_value FROM performance_schema.variables_by_thread
|
|
WHERE variable_name LIKE "example_%" ORDER BY variable_value;
|
|
|
|
--echo #
|
|
--echo # ================================================================================
|
|
--echo # 3.7 - RECONNECT 3 CLIENTS, SET SESSION VARS FOR EACH
|
|
--echo # ================================================================================
|
|
--connect(con1, localhost, root,,)
|
|
SET SESSION example_double_thdvar = 311.1111;
|
|
--echo #
|
|
--connect(con2, localhost, root,,)
|
|
SET SESSION example_double_thdvar = 322.2222;
|
|
--echo #
|
|
--connect(con3, localhost, root,,)
|
|
SET SESSION example_double_thdvar = 333.3333;
|
|
--echo #
|
|
--connection default
|
|
|
|
--echo #
|
|
--echo # ================================================================================
|
|
--echo # 3.8 - VERIFY GLOBAL AND SESSION VARS
|
|
--echo # ================================================================================
|
|
--source ../include/show_plugin_verifier.inc
|
|
--echo #
|
|
--echo # Variables by thread
|
|
SELECT variable_name, variable_value FROM performance_schema.variables_by_thread
|
|
WHERE variable_name LIKE "example_%" ORDER BY variable_value;
|
|
|
|
--echo #
|
|
--echo # ================================================================================
|
|
--echo # 3.9 - UNINSTALL PLUGIN, LEAVE CLIENTS CONNECTED
|
|
--echo # ================================================================================
|
|
UNINSTALL PLUGIN example;
|
|
|
|
--echo #
|
|
--echo # ================================================================================
|
|
--echo # 3.10 - VERIFY SESSION VARS ARE REMOVED
|
|
--echo # ================================================================================
|
|
--source ../include/show_plugin_verifier.inc
|
|
--echo #
|
|
--echo # VARIABLES BY THREAD
|
|
SELECT variable_name, variable_value FROM performance_schema.variables_by_thread
|
|
WHERE variable_name LIKE "example_%" ORDER BY variable_value;
|
|
|
|
--echo #
|
|
--echo # ================================================================================
|
|
--echo # 3.11 - DISCONNECT CLIENTS
|
|
--echo # ================================================================================
|
|
--disconnect con1
|
|
--disconnect con2
|
|
--disconnect con3
|
|
--connection default
|
|
|
|
--echo #
|
|
--echo # ================================================================================
|
|
--echo # 3.12 - VERIFY CLIENTS ARE REMOVED
|
|
--echo # ================================================================================
|
|
--source ../include/show_plugin_verifier.inc
|
|
--echo #
|
|
--echo # VARIABLES BY THREAD
|
|
SELECT variable_name, variable_value FROM performance_schema.variables_by_thread
|
|
WHERE variable_name LIKE "example_%" ORDER BY variable_value;
|
|
|
|
--echo #
|
|
--echo # ================================================================================
|
|
--echo # TEST 4 - BUG#18008907: DEADLOCK WITH CHANGE_USER, SHOW VARIABLES, INSTALL PLUGIN
|
|
--echo # ================================================================================
|
|
--echo #
|
|
--echo #
|
|
--echo # ================================================================================
|
|
--echo # TEST 5 - BUG#22225549 MYSQL_CHANGE_USER/MYSQL_RESET_CONNECTION + SET INNODB...
|
|
--echo Update to plugin-defined session variable triggers resync with global
|
|
--echo variables and deadlocks on THD::LOCK_thd_sysvar.
|
|
--echo # ================================================================================
|
|
#
|
|
# The deadlock occurs when plugin-defined session variables are resynced with the global
|
|
# variables. To force a resync, change the user and update a session variable from a
|
|
# plugin, in this case InnoDB.
|
|
#
|
|
select @@session.innodb_strict_mode;
|
|
let $innodb_strict_mode_save = `select @@session.innodb_strict_mode`;
|
|
select user(), current_user();
|
|
--echo # change_user root
|
|
--change_user root
|
|
--echo #
|
|
--echo # Trigger a resync of session variables with global variables.
|
|
--echo #
|
|
set @@session.innodb_strict_mode=off;
|
|
|
|
--echo #
|
|
--echo # Restore
|
|
--echo #
|
|
eval set @@session.innodb_strict_mode=$innodb_strict_mode_save;
|
|
select @@session.innodb_strict_mode;
|
|
|
|
--echo #
|
|
--echo # ================================================================================
|
|
--echo # CLEAN UP
|
|
--echo # ================================================================================
|
|
--connection default
|
|
--echo #
|
|
|
|
--echo #
|