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:
committed by
Dmitry Shulga
parent
18985d8471
commit
bead24b7f3
@@ -40,10 +40,7 @@ drop table test.t1;
|
||||
drop table test.t2;
|
||||
drop table test.t3;
|
||||
update performance_schema.setup_instruments set enabled='YES';
|
||||
connection con1;
|
||||
disconnect con1;
|
||||
connection con2;
|
||||
disconnect con2;
|
||||
connection con3;
|
||||
disconnect con3;
|
||||
connection default;
|
||||
|
@@ -30,7 +30,9 @@ GRANT USAGE ON *.* TO `pfsuser`@`localhost`
|
||||
GRANT SELECT, UPDATE ON `performance_schema`.* TO `pfsuser`@`localhost`
|
||||
select * from performance_schema.setup_instruments;
|
||||
update performance_schema.setup_instruments set enabled='NO';
|
||||
ERROR HY000: The MariaDB server is running with the --read-only=ON option so it cannot execute this statement
|
||||
update performance_schema.setup_instruments set enabled='YES';
|
||||
ERROR HY000: The MariaDB server is running with the --read-only=ON option so it cannot execute this statement
|
||||
connection default;
|
||||
grant READ_ONLY ADMIN on *.* to pfsuser@localhost;
|
||||
flush privileges;
|
||||
|
@@ -154,10 +154,8 @@ Expect 2
|
||||
# 5.0 Drop the client connections
|
||||
#==============================================================================
|
||||
# 5.1 Disconnect con1
|
||||
connection con1;
|
||||
disconnect con1;
|
||||
# 5.2 Disconnect con2
|
||||
connection con2;
|
||||
disconnect con2;
|
||||
connection default;
|
||||
#==============================================================================
|
||||
|
@@ -199,11 +199,8 @@ wait/io/socket/sql/client_connection <LOCALHOST>
|
||||
wait/io/socket/sql/client_connection <LOCALHOST>
|
||||
wait/io/socket/sql/client_connection
|
||||
connection default;
|
||||
connection con1;
|
||||
disconnect con1;
|
||||
connection con2;
|
||||
disconnect con2;
|
||||
connection con3;
|
||||
disconnect con3;
|
||||
connection default;
|
||||
# After waiting a bit we should have no differences to socket_instances
|
||||
|
@@ -117,12 +117,10 @@ consistent with totals in socket_summary_by_instance
|
||||
#
|
||||
# 5.1 Disconnect con1
|
||||
#
|
||||
connection con1;
|
||||
disconnect con1;
|
||||
#
|
||||
# 5.2 Disconnect con2
|
||||
#
|
||||
connection con2;
|
||||
disconnect con2;
|
||||
#
|
||||
# 5.3 Drop mysqltest
|
||||
|
@@ -219,4 +219,3 @@ connection default;
|
||||
# It must reset all counters.
|
||||
TRUNCATE TABLE performance_schema.socket_summary_by_instance;
|
||||
# 6. Cleanup
|
||||
connection default;
|
||||
|
@@ -951,10 +951,6 @@ where THREAD_ID = $con4_thread_id;
|
||||
count(*)
|
||||
0
|
||||
connection default;
|
||||
revoke all privileges, grant option from user1@localhost;
|
||||
revoke all privileges, grant option from user2@localhost;
|
||||
revoke all privileges, grant option from user3@localhost;
|
||||
revoke all privileges, grant option from user4@localhost;
|
||||
drop user user1@localhost;
|
||||
drop user user2@localhost;
|
||||
drop user user3@localhost;
|
||||
|
@@ -1272,7 +1272,6 @@ DELETE FROM db.t1;
|
||||
#=======================================================================
|
||||
# Cleanup
|
||||
#=======================================================================
|
||||
connection con1;
|
||||
disconnect con1;
|
||||
connection default;
|
||||
DROP DATABASE db;
|
||||
|
Reference in New Issue
Block a user