1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

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
This commit is contained in:
Sergei Golubchik
2025-06-12 00:43:26 +02:00
committed by Dmitry Shulga
parent 18985d8471
commit bead24b7f3
347 changed files with 131 additions and 2015 deletions

View File

@@ -1217,11 +1217,8 @@ connection default;
# Reaping 'handler t1 read a next'...
ERROR 42S02: Table 'test.t1' doesn't exist
handler t1 close;
connection con1;
disconnect con1;
connection con2;
disconnect con2;
connection con3;
disconnect con3;
connection default;
#
@@ -1377,7 +1374,6 @@ a b
handler t1 close;
# Cleanup.
drop table t1;
connection con1;
disconnect con1;
connection default;
#
@@ -1527,7 +1523,6 @@ ERROR 42S02: Table 'test.t1' doesn't exist
HANDLER t1 READ id NEXT;
ERROR 42S02: Table 'test.t1' doesn't exist
HANDLER t1 CLOSE;
connection con51355;
disconnect con51355;
connection default;
#

View File

@@ -993,15 +993,9 @@ connection default;
--reap
handler t1 close;
connection con1;
disconnect con1;
--source include/wait_until_disconnected.inc
connection con2;
disconnect con2;
--source include/wait_until_disconnected.inc
connection con3;
disconnect con3;
--source include/wait_until_disconnected.inc
connection default;
--echo #
@@ -1110,9 +1104,7 @@ handler t1 read a prev;
handler t1 close;
--echo # Cleanup.
drop table t1;
connection con1;
disconnect con1;
--source include/wait_until_disconnected.inc
connection default;
--echo #
@@ -1280,12 +1272,9 @@ HANDLER t1 READ id NEXT;
HANDLER t1 READ id NEXT;
HANDLER t1 CLOSE;
connection con51355;
disconnect con51355;
--source include/wait_until_disconnected.inc
connection default;
--echo #
--echo # Bug#54401 assert in Diagnostics_area::set_eof_status , HANDLER
--echo #

View File

@@ -1216,11 +1216,8 @@ connection default;
# Reaping 'handler t1 read a next'...
ERROR 42S02: Table 'test.t1' doesn't exist
handler t1 close;
connection con1;
disconnect con1;
connection con2;
disconnect con2;
connection con3;
disconnect con3;
connection default;
#
@@ -1376,7 +1373,6 @@ a b
handler t1 close;
# Cleanup.
drop table t1;
connection con1;
disconnect con1;
connection default;
#
@@ -1526,7 +1522,6 @@ ERROR 42S02: Table 'test.t1' doesn't exist
HANDLER t1 READ id NEXT;
ERROR 42S02: Table 'test.t1' doesn't exist
HANDLER t1 CLOSE;
connection con51355;
disconnect con51355;
connection default;
#

View File

@@ -1221,11 +1221,8 @@ connection default;
# Reaping 'handler t1 read a next'...
ERROR 42S02: Table 'test.t1' doesn't exist
handler t1 close;
connection con1;
disconnect con1;
connection con2;
disconnect con2;
connection con3;
disconnect con3;
connection default;
#
@@ -1381,7 +1378,6 @@ a b
handler t1 close;
# Cleanup.
drop table t1;
connection con1;
disconnect con1;
connection default;
#
@@ -1531,7 +1527,6 @@ ERROR 42S02: Table 'test.t1' doesn't exist
HANDLER t1 READ id NEXT;
ERROR 42S02: Table 'test.t1' doesn't exist
HANDLER t1 CLOSE;
connection con51355;
disconnect con51355;
connection default;
#
@@ -1753,11 +1748,8 @@ commit;
#
# Cleanup for savepoint.inc
#
connection con1;
disconnect con1;
connection con2;
disconnect con2;
connection con3;
disconnect con3;
connection default;
CREATE TABLE t1 (f1 integer, f2 integer, primary key (f1), key (f2)) engine=innodb;

View File

@@ -223,9 +223,7 @@ handler t1 close;
ERROR 42S02: Unknown table 't1' in HANDLER
connection default;
drop table t0;
connection flush;
disconnect flush;
connection waiter;
disconnect waiter;
connection default;
create table t1 (a int);
@@ -295,7 +293,6 @@ handler t1 close;
connection con1;
drop table t1;
disconnect con1;
connection con2;
disconnect con2;
connection default;
USE information_schema;

View File

@@ -243,12 +243,8 @@ handler t1 read next;
handler t1 close;
connection default;
drop table t0;
connection flush;
disconnect flush;
--source include/wait_until_disconnected.inc
connection waiter;
disconnect waiter;
--source include/wait_until_disconnected.inc
connection default;
#
@@ -325,10 +321,7 @@ connection con1;
--reap # Since last in this connection was a send
drop table t1;
disconnect con1;
--source include/wait_until_disconnected.inc
connection con2;
disconnect con2;
--source include/wait_until_disconnected.inc
connection default;
#

View File

@@ -1217,11 +1217,8 @@ connection default;
# Reaping 'handler t1 read a next'...
ERROR 42S02: Table 'test.t1' doesn't exist
handler t1 close;
connection con1;
disconnect con1;
connection con2;
disconnect con2;
connection con3;
disconnect con3;
connection default;
#
@@ -1377,7 +1374,6 @@ a b
handler t1 close;
# Cleanup.
drop table t1;
connection con1;
disconnect con1;
connection default;
#
@@ -1527,7 +1523,6 @@ ERROR 42S02: Table 'test.t1' doesn't exist
HANDLER t1 READ id NEXT;
ERROR 42S02: Table 'test.t1' doesn't exist
HANDLER t1 CLOSE;
connection con51355;
disconnect con51355;
connection default;
#

View File

@@ -170,13 +170,7 @@ commit;
--echo #
--echo # Cleanup for savepoint.inc
--echo #
connection con1;
disconnect con1;
--source include/wait_until_disconnected.inc
connection con2;
disconnect con2;
--source include/wait_until_disconnected.inc
connection con3;
disconnect con3;
--source include/wait_until_disconnected.inc
connection default;