mirror of
				https://github.com/MariaDB/server.git
				synced 2025-10-31 19:06:14 +01:00 
			
		
		
		
	 35a9c90fff
			
		
	
	
	35a9c90fff
	
	
	
		
			
			When the transaction isolation level is SERIALIZABLE, or when a locking read is performed in the REPEATABLE READ isolation level, InnoDB must lock delete-marked records in order to prevent another transaction from inserting something. However, at READ UNCOMMITTED or READ COMMITTED isolation level or when the parameter innodb_locks_unsafe_for_binlog is set, the repeatability of the reads does not matter, and there is no need to lock any records. row_search_for_mysql(): Skip locks on delete-marked committed records upfront, instead of invoking row_unlock_for_mysql() afterwards. The unlocking never worked for secondary index records.
		
			
				
	
	
		
			72 lines
		
	
	
	
		
			1.5 KiB
		
	
	
	
		
			Text
		
	
	
	
	
	
			
		
		
	
	
			72 lines
		
	
	
	
		
			1.5 KiB
		
	
	
	
		
			Text
		
	
	
	
	
	
| --source include/have_innodb.inc
 | |
| --source include/have_debug.inc
 | |
| --source include/have_debug_sync.inc
 | |
| 
 | |
| --source include/count_sessions.inc
 | |
| 
 | |
| connect(stop_purge, localhost, root,,);
 | |
| START TRANSACTION WITH CONSISTENT SNAPSHOT;
 | |
| connect(delete, localhost, root,,);
 | |
| connection default;
 | |
| 
 | |
| CREATE TABLE t1(a INT PRIMARY KEY, b INT UNIQUE) ENGINE=InnoDB;
 | |
| INSERT INTO t1 VALUES(1,1);
 | |
| DELETE FROM t1;
 | |
| 
 | |
| let $i=2;
 | |
| while ($i) {
 | |
| let $iso= `SELECT CASE $i WHEN 1 THEN 'UNCOMMITTED' ELSE 'COMMITTED' END`;
 | |
| 
 | |
| SET DEBUG_SYNC='row_ins_sec_index_unique SIGNAL inserted WAIT_FOR locked';
 | |
| BEGIN;
 | |
| send INSERT INTO t1 VALUES(1,1);
 | |
| 
 | |
| connection delete;
 | |
| SET DEBUG_SYNC='now WAIT_FOR inserted';
 | |
| SET DEBUG_SYNC='innodb_row_search_for_mysql_exit SIGNAL locked';
 | |
| eval SET SESSION TRANSACTION ISOLATION LEVEL READ $iso;
 | |
| BEGIN;
 | |
| send DELETE FROM t1 WHERE b=1;
 | |
| 
 | |
| connection default;
 | |
| reap;
 | |
| connection delete;
 | |
| reap;
 | |
| COMMIT;
 | |
| 
 | |
| connection default;
 | |
| SET DEBUG_SYNC='RESET';
 | |
| ROLLBACK;
 | |
| 
 | |
| dec $i;
 | |
| }
 | |
| 
 | |
| SET DEBUG_SYNC='row_ins_sec_index_unique SIGNAL inserted WAIT_FOR locked';
 | |
| BEGIN;
 | |
| SET innodb_lock_wait_timeout=1;
 | |
| send INSERT INTO t1 VALUES(1,1);
 | |
| 
 | |
| connection delete;
 | |
| SET DEBUG_SYNC='now WAIT_FOR inserted';
 | |
| SET DEBUG_SYNC='innodb_row_search_for_mysql_exit SIGNAL locked';
 | |
| SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
 | |
| BEGIN;
 | |
| send DELETE FROM t1 WHERE b=1;
 | |
| 
 | |
| connection default;
 | |
| --error ER_LOCK_WAIT_TIMEOUT
 | |
| reap;
 | |
| COMMIT;
 | |
| SET DEBUG_SYNC='RESET';
 | |
| 
 | |
| connection delete;
 | |
| reap;
 | |
| COMMIT;
 | |
| 
 | |
| disconnect delete;
 | |
| disconnect stop_purge;
 | |
| 
 | |
| connection default;
 | |
| DROP TABLE t1;
 | |
| 
 | |
| --source include/wait_until_count_sessions.inc
 |