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
59 lines
1.8 KiB
Plaintext
59 lines
1.8 KiB
Plaintext
--source include/have_innodb.inc
|
|
|
|
--echo #
|
|
--echo # Bug #19183565 CREATE DYNAMIC INNODB_TMPDIR VARIABLE TO CONTROL
|
|
--echo # WHERE INNODB WRITES TEMP FILES
|
|
--echo #
|
|
|
|
--echo # If innodb_tmpdir is NULL or "", temporary file will be created in
|
|
--echo # server configuration variable location(--tmpdir)
|
|
|
|
create table t1(a int primary key)engine=innodb;
|
|
show session variables like 'innodb_tmpdir';
|
|
alter table t1 add column b int not null;
|
|
set global innodb_tmpdir=NULL;
|
|
connect (con1,localhost,root);
|
|
show session variables like 'innodb_tmpdir';
|
|
alter table t1 add key(b);
|
|
connection default;
|
|
disconnect con1;
|
|
drop table t1;
|
|
|
|
--echo # innodb_tmpdir with invalid path.
|
|
|
|
create table t1(a int primary key)engine=innodb;
|
|
--error ER_WRONG_VALUE_FOR_VAR
|
|
set global innodb_tmpdir='wrong_value';
|
|
show warnings;
|
|
drop table t1;
|
|
|
|
|
|
--echo # innodb_tmpdir with mysql data directory path.
|
|
|
|
let $MYSQLD_DATADIR= `select @@datadir`;
|
|
create table t1(a text, b text, fulltext(a,b))engine=innodb;
|
|
insert into t1 values('test1', 'test2');
|
|
insert into t1 values('text1', 'text2');
|
|
--replace_result $MYSQLD_DATADIR MYSQL_DATADIR
|
|
--error ER_WRONG_VALUE_FOR_VAR
|
|
set global innodb_tmpdir = @@global.datadir;
|
|
--replace_regex /.*mysqld.1/DATADIR/
|
|
show warnings;
|
|
drop table t1;
|
|
|
|
--echo # innodb_tmpdir with valid location.
|
|
let $MYSQL_TMP_DIR= `select @@tmpdir`;
|
|
create table t1(a text, b text, fulltext(a,b))engine=innodb;
|
|
insert into t1 values('test1', 'test2');
|
|
insert into t1 values('text1', 'text2');
|
|
set @tmpdir = @@global.tmpdir;
|
|
set global innodb_tmpdir = @tmpdir;
|
|
show session variables like 'innodb_tmpdir';
|
|
connect (con3,localhost,root);
|
|
# Following alter using innodb_tmpdir as a path to create temporary files
|
|
alter table t1 add fulltext(b);
|
|
disconnect con3;
|
|
connection default;
|
|
set global innodb_tmpdir=NULL;
|
|
drop table t1;
|