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
153 lines
3.0 KiB
Plaintext
153 lines
3.0 KiB
Plaintext
#
|
|
# DELETE LOW_PRIORITY
|
|
#
|
|
--source have_engine.inc
|
|
|
|
--let $create_definiiton = a $int_col, b $char_col
|
|
--source create_table.inc
|
|
INSERT INTO t1 (a,b) VALUES (1,'f'),(2,'b');
|
|
|
|
# We will have 3 connections:
|
|
# con1 will start SELECT which should give us enough time;
|
|
# default will run DELETE
|
|
# con2 will then start another SELECT.
|
|
# With LOW_PRIORITY_UPDATES = 0,
|
|
# with standard DELETE we should see all rows in con1 resultset,
|
|
# but no rows in con2 resultset.
|
|
# With DELETE LOW_PRIORITY we should see all rows in both resultsets.
|
|
# Then we will set LOW_PRIORITY_UPDATES to 1.
|
|
# Then with standard DELETE we should see all rows in both resultsets.
|
|
|
|
SET LOW_PRIORITY_UPDATES = 0;
|
|
SET lock_wait_timeout = 4;
|
|
|
|
# Normal DELETE with low_priority_updates=0
|
|
|
|
--connect (con1,localhost,root,,)
|
|
SET lock_wait_timeout = 2;
|
|
--send
|
|
SELECT SLEEP(1) FROM t1;
|
|
|
|
--connection default
|
|
let $show_statement = SHOW PROCESSLIST;
|
|
let $field = State;
|
|
let $condition = = 'User sleep';
|
|
# We don't need to wait long,
|
|
# if the feature works, threads
|
|
# should show up in the processlist right away
|
|
let $wait_timeout = 2;
|
|
--source include/wait_show_condition.inc
|
|
|
|
--send
|
|
DELETE FROM t1;
|
|
|
|
--connect (con2,localhost,root,,)
|
|
SET lock_wait_timeout = 3;
|
|
|
|
let $field = Info;
|
|
let $condition = = 'DELETE FROM t1';
|
|
let $wait_timeout = 2;
|
|
--source include/wait_show_condition.inc
|
|
if (!$found)
|
|
{
|
|
--let $mysql_errname = timeout in wait_show_condition.inc
|
|
--let $functionality = DELETE or table locking
|
|
--source unexpected_result.inc
|
|
}
|
|
if ($found)
|
|
{
|
|
SELECT SLEEP(1) FROM t1;
|
|
}
|
|
|
|
--connection con1
|
|
--reap
|
|
|
|
--connection default
|
|
--reap
|
|
--sorted_result
|
|
SELECT a,b FROM t1;
|
|
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
|
|
|
|
|
|
# DELETE LOW_PRIORITY
|
|
|
|
--connection con1
|
|
--send
|
|
SELECT SLEEP(1) FROM t1;
|
|
|
|
--connection default
|
|
let $field = State;
|
|
let $condition = = 'User sleep';
|
|
let $wait_timeout = 2;
|
|
--source include/wait_show_condition.inc
|
|
--send
|
|
DELETE LOW_PRIORITY FROM t1;
|
|
|
|
--connection con2
|
|
let $field = Info;
|
|
let $condition = = 'DELETE LOW_PRIORITY FROM t1';
|
|
let $wait_timeout = 2;
|
|
--source include/wait_show_condition.inc
|
|
if (!$found)
|
|
{
|
|
--let $mysql_errname = timeout in wait_show_condition.inc
|
|
--let $functionality = DELETE LOW_PRIORITY or table locking
|
|
--source unexpected_result.inc
|
|
}
|
|
if ($found)
|
|
{
|
|
SELECT SLEEP(1) FROM t1;
|
|
}
|
|
|
|
--connection con1
|
|
--reap
|
|
|
|
--connection default
|
|
--reap
|
|
--sorted_result
|
|
SELECT a,b FROM t1;
|
|
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
|
|
|
|
SET LOW_PRIORITY_UPDATES = 1;
|
|
|
|
# Normal DELETE with low_priority_updates=1
|
|
|
|
--connection con1
|
|
--send
|
|
SELECT SLEEP(1) FROM t1;
|
|
|
|
--connection default
|
|
let $field = State;
|
|
let $condition = = 'User sleep';
|
|
let $wait_timeout = 2;
|
|
--source include/wait_show_condition.inc
|
|
--send
|
|
DELETE FROM t1;
|
|
|
|
--connection con2
|
|
let $field = Info;
|
|
let $condition = = 'DELETE FROM t1';
|
|
let $wait_timeout = 2;
|
|
--source include/wait_show_condition.inc
|
|
if ($found)
|
|
{
|
|
SELECT SLEEP(1) FROM t1;
|
|
}
|
|
|
|
--connection con1
|
|
--reap
|
|
|
|
--connection default
|
|
--reap
|
|
--sorted_result
|
|
SELECT a,b FROM t1;
|
|
|
|
--disconnect con1
|
|
--disconnect con2
|
|
|
|
# Cleanup
|
|
DROP TABLE t1;
|
|
|
|
--source cleanup_engine.inc
|
|
|