mirror of
https://github.com/MariaDB/server.git
synced 2025-08-13 14:01:33 +02: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
62 lines
1.6 KiB
Text
62 lines
1.6 KiB
Text
-- source include/have_log_bin.inc
|
|
-- source include/have_innodb.inc
|
|
-- source include/not_binlog_format_row.inc
|
|
|
|
--disable_query_log
|
|
call mtr.add_suppression("InnoDB: Transaction was aborted due to ");
|
|
--enable_query_log
|
|
|
|
--echo #
|
|
--echo # Bug #39022: Mysql randomly crashing in lock_sec_rec_cons_read_sees
|
|
--echo #
|
|
|
|
--disable_ps2_protocol
|
|
call mtr.add_suppression("Deadlock found when trying to get lock; try restarting transaction");
|
|
|
|
CREATE TABLE t1(a TINYINT NOT NULL,b TINYINT,PRIMARY KEY(b)) ENGINE=innodb;
|
|
CREATE TABLE t2(d TINYINT NOT NULL,UNIQUE KEY(d)) ENGINE=innodb;
|
|
INSERT INTO t1 VALUES (13,0),(8,1),(9,2),(6,3),
|
|
(11,5),(11,6),(7,7),(7,8),(4,9),(6,10),(3,11),(11,12),
|
|
(12,13),(7,14);
|
|
INSERT INTO t2 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9),(10),
|
|
(11),(12),(13),(14);
|
|
|
|
connect (thread1, localhost, root,,);
|
|
connect (thread2, localhost, root,,);
|
|
|
|
connection thread1;
|
|
START TRANSACTION;
|
|
|
|
connection thread2;
|
|
REPLACE INTO t2 VALUES (-17);
|
|
SELECT d FROM t2,t1 WHERE d=(SELECT MAX(a) FROM t1 WHERE t1.a > t2.d) LOCK IN SHARE MODE;
|
|
|
|
connection thread1;
|
|
REPLACE INTO t1(a,b) VALUES (67,20);
|
|
|
|
connection thread2;
|
|
COMMIT;
|
|
START TRANSACTION;
|
|
REPLACE INTO t1(a,b) VALUES (65,-50);
|
|
REPLACE INTO t2 VALUES (-91);
|
|
send;
|
|
SELECT d FROM t2,t1 WHERE d=(SELECT MAX(a) FROM t1 WHERE t1.a > t2.d) LOCK IN SHARE MODE; #waits
|
|
|
|
connection thread1;
|
|
|
|
--echo # should not crash
|
|
--error ER_LOCK_DEADLOCK,ER_LOCK_WAIT_TIMEOUT
|
|
SELECT d FROM t2,t1 WHERE d=(SELECT MAX(a) FROM t1 WHERE t1.a > t2.d) LOCK IN SHARE MODE; #crashes
|
|
|
|
connection thread2;
|
|
REAP;
|
|
|
|
disconnect thread2;
|
|
|
|
connection thread1;
|
|
disconnect thread1;
|
|
|
|
connection default;
|
|
|
|
DROP TABLE t1,t2;
|
|
--enable_ps2_protocol
|