1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00
Files
mariadb/mysql-test/suite/sys_vars/t/debug_dbug_func.test
Sergei Golubchik bead24b7f3 mariadb-test: wait on disconnect
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
2025-07-16 09:14:33 +07:00

123 lines
3.1 KiB
Plaintext

--source include/have_debug.inc
SET @old_debug = @@GLOBAL.debug_dbug;
#
# Bug#34678 @@debug_dbug variable's incremental mode
#
SET debug_dbug= 'T';
select @@debug_dbug;
SET debug_dbug= '+P';
select @@debug_dbug;
SET debug_dbug= '-P';
select @@debug_dbug;
#
# Bug#38054: "SET SESSION debug" modifies @@global.debug_dbug variable
#
SELECT @@session.debug_dbug, @@global.debug_dbug;
SET SESSION debug_dbug= '';
SELECT @@session.debug_dbug, @@global.debug_dbug;
--echo #
--echo # Bug #52629: memory leak from sys_var_thd_dbug in
--echo # binlog.binlog_write_error
--echo #
SET GLOBAL debug_dbug='d,injecting_fault_writing';
SELECT @@global.debug_dbug;
SET GLOBAL debug_dbug='';
SELECT @@global.debug_dbug;
SET GLOBAL debug_dbug=@old_debug;
--echo #
--echo # Bug #56709: Memory leaks at running the 5.1 test suite
--echo #
SET @old_local_debug = @@debug_dbug;
SET @@debug_dbug='d,foo';
SELECT @@debug_dbug;
SET @@debug_dbug='';
SELECT @@debug_dbug;
SET @@debug_dbug= @old_local_debug;
--echo End of 5.1 tests
--echo #
--echo # Bug#46165 server crash in dbug
--echo #
SET @old_globaldebug = @@global.debug_dbug;
SET @old_sessiondebug= @@session.debug_dbug;
--echo # Test 1 - Bug test case, single connection
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
eval SET GLOBAL debug_dbug= '+O,$MYSQL_TMP_DIR/bug46165.1.trace';
SET SESSION debug_dbug= '-d:-t:-i';
SET GLOBAL debug_dbug= '';
SET SESSION debug_dbug= '';
--echo # Test 2 - Bug test case, two connections
connection default;
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
eval SET GLOBAL debug_dbug= '+O,$MYSQL_TMP_DIR/bug46165.2.trace';
SET SESSION debug_dbug= '-d:-t:-i';
connect (con1, localhost, root);
SET GLOBAL debug_dbug= '';
connection default;
SET SESSION debug_dbug= '';
disconnect con1;
connection default;
SET GLOBAL debug_dbug= '';
--echo # Test 3 - Active session trace file on disconnect
connect (con1, localhost, root);
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
eval SET GLOBAL debug_dbug= '+O,$MYSQL_TMP_DIR/bug46165.3.trace';
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
SELECT @@global.debug_dbug, @@session.debug_dbug;
SET SESSION debug_dbug= '+T';
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
SELECT @@global.debug_dbug, @@session.debug_dbug;
SET GLOBAL debug_dbug= '';
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
SELECT @@global.debug_dbug, @@session.debug_dbug;
disconnect con1;
--echo # Test 4 - Active session trace file on two connections
connection default;
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
eval SET GLOBAL debug_dbug= '+O,$MYSQL_TMP_DIR/bug46165.4.trace';
SET SESSION debug_dbug= '-d:-t:-i';
connect (con1, localhost, root);
SET SESSION debug_dbug= '-d:-t:-i';
SET GLOBAL debug_dbug= '';
SET SESSION debug_dbug= '';
connection default;
SET SESSION debug_dbug= '';
disconnect con1;
connection default;
--echo # Test 5 - Different trace files
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
eval SET SESSION debug_dbug= '+O,$MYSQL_TMP_DIR/bug46165.5.trace';
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
eval SET SESSION debug_dbug= '+O,$MYSQL_TMP_DIR/bug46165.6.trace';
SET SESSION debug_dbug= '-O';
SET GLOBAL debug_dbug= @old_globaldebug;
SET SESSION debug_dbug= @old_sessiondebug;