1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00
Files
mariadb/mysql-test/suite/innodb/t/create_select.test
Sergei Golubchik bead24b7f3 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
2025-07-16 09:14:33 +07:00

73 lines
2.0 KiB
Plaintext

--source include/have_innodb.inc
--source include/have_sequence.inc
--source include/maybe_debug.inc
let $ID= `SELECT @id := CONNECTION_ID()`;
connect (con1, localhost, root,,);
let $ignore= `SELECT @id := $ID`;
connection default;
send CREATE TABLE t1 ENGINE=InnoDB SELECT * FROM seq_1_to_100000000;
connection con1;
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = 'Sending data'
and info = 'CREATE TABLE t1 ENGINE=InnoDB SELECT * FROM seq_1_to_100000000';
--source include/wait_condition.inc
KILL QUERY @id;
connection default;
--error ER_QUERY_INTERRUPTED
reap;
CREATE TABLE t1 (a SERIAL) ENGINE=InnoDB;
DROP TABLE t1;
--echo # End of 10.2 tests
--echo #
--echo # MDEV-35236 Assertion `(mem_root->flags & 4) == 0' failed in safe_lexcstrdup_root
--echo #
prepare stmt from 'create or replace table t engine=innodb select 1 as f';
set innodb_compression_default=on;
execute stmt;
execute stmt;
drop table t;
--echo # End of 10.5 tests
--echo #
--echo # MDEV-35647 Possible hang during CREATE TABLE…SELECT error handling
--echo #
call mtr.add_suppression("InnoDB: DROP TABLE `test`\\.`t4`: Record changed");
--error 0,ER_UNKNOWN_SYSTEM_VARIABLE
SET @save_debug= @@GLOBAL.innodb_evict_tables_on_commit_debug;
--error 0,ER_UNKNOWN_SYSTEM_VARIABLE
SET GLOBAL innodb_evict_tables_on_commit_debug=on;
CREATE TABLE t1 (a INT) ENGINE=InnoDB;
--error 0,ER_UNKNOWN_SYSTEM_VARIABLE
SET GLOBAL innodb_evict_tables_on_commit_debug=@save_debug;
connection con1;
CREATE TABLE t2 (b BLOB) ENGINE=InnoDB;
INSERT INTO t2 VALUES (1),('2025-01-21 00:00:00');
--send
SET STATEMENT innodb_snapshot_isolation=ON FOR
CREATE TABLE t3 ENGINE=InnoDB AS SELECT * FROM t1;
connection default;
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
--error ER_TRUNCATED_WRONG_VALUE
SET STATEMENT innodb_snapshot_isolation=ON FOR
CREATE TABLE t4 (b BLOB CHECK (b)) ENGINE=InnoDB AS SELECT b FROM t2;
connection con1;
reap;
disconnect con1;
connection default;
DROP TABLE t3,t2,t1;
--echo # End of 10.6 tests