mirror of
				https://github.com/MariaDB/server.git
				synced 2025-11-04 04:46:15 +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
		
			
				
	
	
		
			101 lines
		
	
	
	
		
			2.9 KiB
		
	
	
	
		
			Text
		
	
	
	
	
	
			
		
		
	
	
			101 lines
		
	
	
	
		
			2.9 KiB
		
	
	
	
		
			Text
		
	
	
	
	
	
SET @old_debug = @@GLOBAL.debug_dbug;
 | 
						|
SET debug_dbug= 'T';
 | 
						|
select @@debug_dbug;
 | 
						|
@@debug_dbug
 | 
						|
T
 | 
						|
SET debug_dbug= '+P';
 | 
						|
select @@debug_dbug;
 | 
						|
@@debug_dbug
 | 
						|
P:T
 | 
						|
SET debug_dbug= '-P';
 | 
						|
select @@debug_dbug;
 | 
						|
@@debug_dbug
 | 
						|
T
 | 
						|
SELECT @@session.debug_dbug, @@global.debug_dbug;
 | 
						|
@@session.debug_dbug	@@global.debug_dbug
 | 
						|
T	
 | 
						|
SET SESSION debug_dbug= '';
 | 
						|
SELECT @@session.debug_dbug, @@global.debug_dbug;
 | 
						|
@@session.debug_dbug	@@global.debug_dbug
 | 
						|
	
 | 
						|
#
 | 
						|
# Bug #52629: memory leak from sys_var_thd_dbug in 
 | 
						|
#  binlog.binlog_write_error
 | 
						|
#
 | 
						|
SET GLOBAL debug_dbug='d,injecting_fault_writing';
 | 
						|
SELECT @@global.debug_dbug;
 | 
						|
@@global.debug_dbug
 | 
						|
d,injecting_fault_writing
 | 
						|
SET GLOBAL debug_dbug='';
 | 
						|
SELECT @@global.debug_dbug;
 | 
						|
@@global.debug_dbug
 | 
						|
 | 
						|
SET GLOBAL debug_dbug=@old_debug;
 | 
						|
#
 | 
						|
# Bug #56709: Memory leaks at running the 5.1 test suite
 | 
						|
# 
 | 
						|
SET @old_local_debug = @@debug_dbug;
 | 
						|
SET @@debug_dbug='d,foo';
 | 
						|
SELECT @@debug_dbug;
 | 
						|
@@debug_dbug
 | 
						|
d,foo
 | 
						|
SET @@debug_dbug='';
 | 
						|
SELECT @@debug_dbug;
 | 
						|
@@debug_dbug
 | 
						|
 | 
						|
SET @@debug_dbug= @old_local_debug;
 | 
						|
End of 5.1 tests
 | 
						|
#
 | 
						|
# Bug#46165 server crash in dbug
 | 
						|
#
 | 
						|
SET @old_globaldebug = @@global.debug_dbug;
 | 
						|
SET @old_sessiondebug= @@session.debug_dbug;
 | 
						|
# Test 1 - Bug test case, single connection
 | 
						|
SET GLOBAL  debug_dbug= '+O,MYSQL_TMP_DIR/bug46165.1.trace';
 | 
						|
SET SESSION debug_dbug= '-d:-t:-i';
 | 
						|
SET GLOBAL  debug_dbug= '';
 | 
						|
SET SESSION debug_dbug= '';
 | 
						|
# Test 2 - Bug test case, two connections
 | 
						|
connection default;
 | 
						|
SET GLOBAL  debug_dbug= '+O,MYSQL_TMP_DIR/bug46165.2.trace';
 | 
						|
SET SESSION debug_dbug= '-d:-t:-i';
 | 
						|
connect  con1, localhost, root;
 | 
						|
SET GLOBAL  debug_dbug= '';
 | 
						|
connection default;
 | 
						|
SET SESSION debug_dbug= '';
 | 
						|
disconnect con1;
 | 
						|
connection default;
 | 
						|
SET GLOBAL  debug_dbug= '';
 | 
						|
# Test 3 - Active session trace file on disconnect
 | 
						|
connect  con1, localhost, root;
 | 
						|
SET GLOBAL  debug_dbug= '+O,MYSQL_TMP_DIR/bug46165.3.trace';
 | 
						|
SELECT @@global.debug_dbug, @@session.debug_dbug;
 | 
						|
@@global.debug_dbug	@@session.debug_dbug
 | 
						|
O,MYSQL_TMP_DIR/bug46165.3.trace	O,MYSQL_TMP_DIR/bug46165.3.trace
 | 
						|
SET SESSION debug_dbug= '+T';
 | 
						|
SELECT @@global.debug_dbug, @@session.debug_dbug;
 | 
						|
@@global.debug_dbug	@@session.debug_dbug
 | 
						|
O,MYSQL_TMP_DIR/bug46165.3.trace	O,MYSQL_TMP_DIR/bug46165.3.trace:T
 | 
						|
SET GLOBAL  debug_dbug= '';
 | 
						|
SELECT @@global.debug_dbug, @@session.debug_dbug;
 | 
						|
@@global.debug_dbug	@@session.debug_dbug
 | 
						|
	O,MYSQL_TMP_DIR/bug46165.3.trace:T
 | 
						|
disconnect con1;
 | 
						|
# Test 4 - Active session trace file on two connections
 | 
						|
connection default;
 | 
						|
SET GLOBAL  debug_dbug= '+O,MYSQL_TMP_DIR/bug46165.4.trace';
 | 
						|
SET SESSION debug_dbug= '-d:-t:-i';
 | 
						|
connect  con1, localhost, root;
 | 
						|
SET SESSION debug_dbug= '-d:-t:-i';
 | 
						|
SET GLOBAL  debug_dbug= '';
 | 
						|
SET SESSION debug_dbug= '';
 | 
						|
connection default;
 | 
						|
SET SESSION debug_dbug= '';
 | 
						|
disconnect con1;
 | 
						|
connection default;
 | 
						|
# Test 5 - Different trace files
 | 
						|
SET SESSION debug_dbug= '+O,MYSQL_TMP_DIR/bug46165.5.trace';
 | 
						|
SET SESSION debug_dbug= '+O,MYSQL_TMP_DIR/bug46165.6.trace';
 | 
						|
SET SESSION debug_dbug= '-O';
 | 
						|
SET GLOBAL  debug_dbug= @old_globaldebug;
 | 
						|
SET SESSION debug_dbug= @old_sessiondebug;
 |