mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +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
104 lines
1.7 KiB
SQL
104 lines
1.7 KiB
SQL
--echo #
|
|
--echo # Start of sp-package-concurrent-dml.inc
|
|
--echo #
|
|
|
|
let $object_type= `SELECT @object_type`;
|
|
|
|
SET sql_mode=ORACLE;
|
|
DELIMITER $$;
|
|
CREATE PACKAGE pkg1 AS
|
|
PROCEDURE p1;
|
|
END;
|
|
$$
|
|
CREATE PACKAGE BODY pkg1 AS
|
|
PROCEDURE p2 AS
|
|
BEGIN
|
|
SELECT 'This is p2' AS msg;
|
|
END;
|
|
PROCEDURE p1 AS
|
|
BEGIN
|
|
SELECT 'This is p1' AS msg;
|
|
DO GET_LOCK('mdev15070',120);
|
|
CALL p2();
|
|
DO RELEASE_LOCK('mdev15070');
|
|
END;
|
|
END;
|
|
$$
|
|
DELIMITER ;$$
|
|
|
|
connect (con2,localhost,root);
|
|
connection con2;
|
|
DO GET_LOCK('mdev15070', 120);
|
|
|
|
connection default;
|
|
send CALL pkg1.p1;
|
|
|
|
connection con2;
|
|
let $wait_condition=
|
|
SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST
|
|
WHERE state = "User lock" AND info LIKE "%GET_LOCK%mdev15070%";
|
|
--source include/wait_condition.inc
|
|
|
|
|
|
if ($object_type==view)
|
|
{
|
|
CREATE VIEW v1 AS SELECT 1 AS c;
|
|
DROP VIEW v1;
|
|
}
|
|
|
|
|
|
if ($object_type==package_replace_pkg1)
|
|
{
|
|
SET sql_mode=ORACLE;
|
|
DELIMITER $$;
|
|
CREATE OR REPLACE PACKAGE pkg1 AS
|
|
PROCEDURE p1;
|
|
END;
|
|
$$
|
|
DELIMITER ;$$
|
|
DROP PACKAGE pkg1;
|
|
}
|
|
|
|
|
|
if ($object_type==package_body_replace_pkg1)
|
|
{
|
|
SET sql_mode=ORACLE;
|
|
DELIMITER $$;
|
|
CREATE OR REPLACE PACKAGE BODY pkg1 AS
|
|
PROCEDURE p1 AS
|
|
BEGIN
|
|
SELECT 'This is p1 version 2' AS msg;
|
|
END;
|
|
END;
|
|
$$
|
|
DELIMITER ;$$
|
|
DROP PACKAGE pkg1;
|
|
}
|
|
|
|
|
|
if ($object_type==trigger)
|
|
{
|
|
CREATE TABLE t1 (a INT);
|
|
CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW SET NEW.a=1;
|
|
DROP TRIGGER tr1;
|
|
DROP TABLE t1;
|
|
}
|
|
|
|
|
|
if ($object_type=='db')
|
|
{
|
|
CREATE DATABASE test1;
|
|
CREATE FUNCTION test1.f1() RETURNS INT RETURN 10;
|
|
DROP DATABASE test1;
|
|
}
|
|
|
|
|
|
DO RELEASE_LOCK('mdev15070');
|
|
|
|
disconnect con2;
|
|
|
|
connection default;
|
|
reap;
|
|
|
|
DROP PACKAGE IF EXISTS pkg1;
|