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
96 lines
3.6 KiB
Plaintext
96 lines
3.6 KiB
Plaintext
# Check if lock_row_lock_current_waits counter in
|
|
# information_schema.innodb_metrics does not become negative after disabling,
|
|
# resetting and enabling.
|
|
|
|
--source include/have_innodb.inc
|
|
--source include/have_debug.inc
|
|
|
|
--connect (prevent_purge,localhost,root,,)
|
|
START TRANSACTION WITH CONSISTENT SNAPSHOT;
|
|
|
|
--connection default
|
|
# lock_row_lock_time_avg is filled under lock_sys.wait_mutex lock, which
|
|
# will be held by connection 2, that is why the following SELECT
|
|
# from information_schema.innodb_metrics will be blocked.
|
|
#
|
|
# And setting innodb_monitor_disable=all causes innodb monitor enabling
|
|
# status changing. The status will not be restored to default value even
|
|
# after
|
|
# -----------------------
|
|
# SET GLOBAL innodb_monitor_reset_all=default;
|
|
# SET GLOBAL innodb_monitor_enable=default;
|
|
# -----------------------
|
|
# execution. See MDEV-32553 for details.
|
|
#
|
|
# All monitors disabling, i.e. "innodb_monitor_disable=all" causes
|
|
# innodb.monitor test failure due to MDEV-32553. 10.5 is not affected, as
|
|
# innodb.monitor differs there.
|
|
#
|
|
# Disable not all monitors at the beginning of the test,
|
|
# but only the monitor, which causes hanging, i.e. lock_row_lock_time_avg.
|
|
SET GLOBAL innodb_monitor_disable='lock_row_lock_time_avg';
|
|
# 'lock_row_lock_current_waits' should be enabled by default;
|
|
CREATE TABLE `t` (a INT PRIMARY KEY) engine=InnoDB STATS_PERSISTENT=0;
|
|
INSERT INTO t VALUES (5);
|
|
SELECT name, count FROM information_schema.innodb_metrics
|
|
WHERE name ='lock_row_lock_current_waits';
|
|
|
|
--connect (con1,localhost,root,,)
|
|
BEGIN;
|
|
SELECT * FROM t FOR UPDATE;
|
|
|
|
--connect (con2,localhost,root,,)
|
|
SET DEBUG_SYNC="lock_wait_before_suspend SIGNAL blocked WAIT_FOR cont";
|
|
BEGIN;
|
|
--send SELECT * FROM t FOR UPDATE
|
|
|
|
--connection default
|
|
SET DEBUG_SYNC="now WAIT_FOR blocked";
|
|
SELECT name, count FROM information_schema.innodb_metrics
|
|
WHERE name ='lock_row_lock_current_waits';
|
|
SET GLOBAL innodb_monitor_disable='lock_row_lock_current_waits';
|
|
SET GLOBAL innodb_monitor_reset_all='lock_row_lock_current_waits';
|
|
SET GLOBAL innodb_monitor_enable='lock_row_lock_current_waits';
|
|
######################################
|
|
# Equals to zero if the bug is not fixed, as MONITOR_DISPLAY_CURRENT is not
|
|
# set for this counter and its value is reset during previous
|
|
# "SET GLOBAL innodb_monitor_reset_all='lock_row_lock_current_waits'" execution.
|
|
#####
|
|
SELECT name, count FROM information_schema.innodb_metrics
|
|
WHERE name ='lock_row_lock_current_waits';
|
|
SET DEBUG_SYNC="now SIGNAL cont";
|
|
|
|
--disconnect con1
|
|
|
|
--connection con2
|
|
--reap
|
|
COMMIT;
|
|
--disconnect con2
|
|
|
|
--connection default
|
|
SET DEBUG_SYNC="reset";
|
|
######################################
|
|
# Equals to -1 if the bug is not fixed. I.e.
|
|
# innodb_counter_value[MONITOR_OVLD_ROW_LOCK_CURRENT_WAIT].mon_start_value is
|
|
# set to 1 during
|
|
# "set global innodb_monitor_disable='lock_row_lock_current_waits'" execution,
|
|
# and the value is counted as
|
|
# (value = 0) - (mon_value_reset = 0) - (mon_start_value = 1) +
|
|
# (mon_last_value = 0) = -1. See MONITOR_SET_DIFF() macro in
|
|
# srv_mon_process_existing_counter() for details.
|
|
#####
|
|
SELECT name, count FROM information_schema.innodb_metrics
|
|
WHERE name ='lock_row_lock_current_waits';
|
|
DROP TABLE `t`;
|
|
SET GLOBAL innodb_monitor_disable='lock_row_lock_current_waits';
|
|
SET GLOBAL innodb_monitor_reset_all='lock_row_lock_current_waits';
|
|
SET GLOBAL innodb_monitor_enable='lock_row_lock_current_waits';
|
|
# TODO: remove it when MDEV-32553 is fixed
|
|
SET GLOBAL innodb_monitor_enable='lock_row_lock_time_avg';
|
|
--disable_warnings
|
|
SET GLOBAL innodb_monitor_disable=default;
|
|
SET GLOBAL innodb_monitor_reset_all=default;
|
|
SET GLOBAL innodb_monitor_enable=default;
|
|
--enable_warnings
|
|
--disconnect prevent_purge
|