mirror of
				https://github.com/MariaDB/server.git
				synced 2025-11-03 20:36:16 +01: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
		
			
				
	
	
		
			127 lines
		
	
	
	
		
			2.6 KiB
		
	
	
	
		
			Text
		
	
	
	
	
	
			
		
		
	
	
			127 lines
		
	
	
	
		
			2.6 KiB
		
	
	
	
		
			Text
		
	
	
	
	
	
--source include/have_debug.inc
 | 
						|
--source include/have_innodb.inc
 | 
						|
--source include/have_debug_sync.inc
 | 
						|
--source include/not_embedded.inc
 | 
						|
 | 
						|
FLUSH TABLES;
 | 
						|
 | 
						|
CREATE TABLE t (
 | 
						|
  a INTEGER,
 | 
						|
  b BLOB GENERATED ALWAYS AS (a) VIRTUAL,
 | 
						|
  INDEX (b(57))
 | 
						|
)ENGINE=INNODB;
 | 
						|
 | 
						|
INSERT INTO t (a) VALUES (9);
 | 
						|
BEGIN;
 | 
						|
SAVEPOINT a;
 | 
						|
UPDATE t set a = 12;
 | 
						|
DELETE FROM t where a = 12;
 | 
						|
ROLLBACK TO SAVEPOINT a;
 | 
						|
COMMIT;
 | 
						|
 | 
						|
CHECK TABLE t;
 | 
						|
 | 
						|
SELECT * FROM t;
 | 
						|
 | 
						|
BEGIN;
 | 
						|
INSERT INTO t (a) VALUES (10);
 | 
						|
--let $shutdown_timeout= 0
 | 
						|
--source include/restart_mysqld.inc
 | 
						|
SELECT * FROM t;
 | 
						|
DROP TABLE t;
 | 
						|
 | 
						|
CREATE TABLE t (
 | 
						|
  a INTEGER,
 | 
						|
  b BLOB GENERATED ALWAYS AS (a) VIRTUAL,
 | 
						|
  c INTEGER
 | 
						|
)ENGINE=INNODB;
 | 
						|
 | 
						|
INSERT INTO t (a,c) VALUES (9, 10);
 | 
						|
SELECT * FROM t;
 | 
						|
 | 
						|
connect (con1,localhost,root,,);
 | 
						|
connection con1;
 | 
						|
 | 
						|
# This DEBUG_SYNC should not kick in yet, because the duplicate key will be
 | 
						|
# detected before we get a chance to apply the online log.
 | 
						|
 | 
						|
SET DEBUG_SYNC = 'row_log_apply_after SIGNAL created WAIT_FOR dml_done';
 | 
						|
--send
 | 
						|
ALTER TABLE t ADD KEY(b(57)), ALGORITHM=INPLACE;
 | 
						|
 | 
						|
connection default;
 | 
						|
SET DEBUG_SYNC = 'now WAIT_FOR created';
 | 
						|
BEGIN;
 | 
						|
INSERT INTO t (a,c) VALUES (10, 12);
 | 
						|
SELECT * FROM t;
 | 
						|
ROLLBACK;
 | 
						|
SET DEBUG_SYNC = 'now SIGNAL dml_done';
 | 
						|
 | 
						|
connection con1;
 | 
						|
reap;
 | 
						|
disconnect con1;
 | 
						|
connection default;
 | 
						|
 | 
						|
SELECT * FROM t;
 | 
						|
DROP TABLE t;
 | 
						|
 | 
						|
# drop virtual column and alter index
 | 
						|
CREATE TABLE t (
 | 
						|
  a INT,
 | 
						|
  b INT,
 | 
						|
  c INT GENERATED ALWAYS AS(a+b),
 | 
						|
  d INT GENERATED ALWAYS AS(a+b+b),
 | 
						|
  KEY(c, d)
 | 
						|
)ENGINE=INNODB;
 | 
						|
 | 
						|
INSERT INTO t (a,b) VALUES (9, 10);
 | 
						|
SELECT * FROM t;
 | 
						|
 | 
						|
connect (con1,localhost,root,,);
 | 
						|
connection con1;
 | 
						|
 | 
						|
# This DEBUG_SYNC should not kick in yet, because the duplicate key will be
 | 
						|
# detected before we get a chance to apply the online log.
 | 
						|
 | 
						|
SET DEBUG_SYNC = 'row_log_apply_after SIGNAL created WAIT_FOR dml_done';
 | 
						|
--send
 | 
						|
ALTER TABLE t DROP COLUMN c, ALGORITHM=INPLACE;
 | 
						|
 | 
						|
connection default;
 | 
						|
SET DEBUG_SYNC = 'now WAIT_FOR created';
 | 
						|
BEGIN;
 | 
						|
INSERT INTO t (a,b) VALUES (10, 12);
 | 
						|
SELECT * FROM t;
 | 
						|
ROLLBACK;
 | 
						|
SET DEBUG_SYNC = 'now SIGNAL dml_done';
 | 
						|
 | 
						|
connection con1;
 | 
						|
reap;
 | 
						|
connection default;
 | 
						|
 | 
						|
SELECT * FROM t;
 | 
						|
 | 
						|
DROP TABLE t;
 | 
						|
SET DEBUG_SYNC = 'RESET';
 | 
						|
 | 
						|
--echo #
 | 
						|
--echo #  MDEV-30597 Assertion `flag == 1' failed in
 | 
						|
--echo #	row_build_index_entry_low
 | 
						|
--echo #
 | 
						|
CREATE TABLE t1 (
 | 
						|
col1 INT PRIMARY KEY, col_text TEXT,
 | 
						|
col_text_g TEXT GENERATED ALWAYS AS (SUBSTR(col_text,1,499))
 | 
						|
) ENGINE = InnoDB ROW_FORMAT = Compact;
 | 
						|
connection con1;
 | 
						|
START TRANSACTION WITH CONSISTENT SNAPSHOT;
 | 
						|
connection default;
 | 
						|
INSERT INTO t1 (col1) VALUES (1) ;
 | 
						|
DELETE FROM t1 WHERE col1 = 1;
 | 
						|
ALTER TABLE t1 ADD UNIQUE INDEX (col_text_g(9));
 | 
						|
BEGIN;
 | 
						|
INSERT INTO t1 (col1) VALUES (1);
 | 
						|
ROLLBACK;
 | 
						|
disconnect con1;
 | 
						|
DROP TABLE t1;
 | 
						|
 | 
						|
--echo # End of 10.4 tests
 |