mirror of
https://github.com/MariaDB/server.git
synced 2025-02-02 12:01:42 +01:00
911c673edf
------------------------------------------------------------ revno: 2617.23.18 committer: Davi Arnaut <Davi.Arnaut@Sun.COM> branch nick: 4284-6.0 timestamp: Mon 2009-03-02 18:18:26 -0300 message: Bug#989: If DROP TABLE while there's an active transaction, wrong binlog order WL#4284: Transactional DDL locking This is a prerequisite patch: These changes are intended to split lock requests from granted locks and to allow the memory and lifetime of granted locks to be managed within the MDL subsystem. Furthermore, tickets can now be shared and therefore are used to satisfy multiple lock requests, but only shared locks can be recursive. The problem is that the MDL subsystem morphs lock requests into granted locks locks but does not manage the memory and lifetime of lock requests, and hence, does not manage the memory of granted locks either. This can be problematic because it puts the burden of tracking references on the users of the subsystem and it can't be easily done in transactional contexts where the locks have to be kept around for the duration of a transaction. Another issue is that recursive locks (when the context trying to acquire a lock already holds a lock on the same object) requires that each time the lock is granted, a unique lock request/granted lock structure structure must be kept around until the lock is released. This can lead to memory leaks in transactional contexts as locks taken during the transaction should only be released at the end of the transaction. This also leads to unnecessary wake ups (broadcasts) in the MDL subsystem if the context still holds a equivalent of the lock being released. These issues are exacerbated due to the fact that WL#4284 low-level design says that the implementation should "2) Store metadata locks in transaction memory root, rather than statement memory root" but this is not possible because a memory root, as implemented in mysys, requires all objects allocated from it to be freed all at once. This patch combines review input and significant code contributions from Konstantin Osipov (kostja) and Dmitri Lenev (dlenev).
69 lines
1.3 KiB
Text
69 lines
1.3 KiB
Text
#
|
|
# We need the Debug Sync Facility.
|
|
#
|
|
--source include/have_debug_sync.inc
|
|
|
|
# Clean up resources used in this test case.
|
|
--disable_warnings
|
|
SET DEBUG_SYNC= 'RESET';
|
|
--enable_warnings
|
|
|
|
#
|
|
# Test the case of when a exclusive lock request waits for a
|
|
# shared lock being upgraded to a exclusive lock.
|
|
#
|
|
|
|
connect (con1,localhost,root,,test,,);
|
|
connect (con2,localhost,root,,test,,);
|
|
connect (con3,localhost,root,,test,,);
|
|
|
|
connection default;
|
|
|
|
--disable_warnings
|
|
drop table if exists t1,t2,t3;
|
|
--enable_warnings
|
|
|
|
create table t1 (i int);
|
|
create table t2 (i int);
|
|
|
|
--echo connection: default
|
|
lock tables t2 read;
|
|
|
|
connection con1;
|
|
--echo connection: con1
|
|
set debug_sync='mdl_upgrade_shared_lock_to_exclusive SIGNAL parked WAIT_FOR go';
|
|
--send alter table t1 rename t3
|
|
|
|
connection default;
|
|
--echo connection: default
|
|
set debug_sync= 'now WAIT_FOR parked';
|
|
|
|
connection con2;
|
|
--echo connection: con2
|
|
set debug_sync='mdl_acquire_exclusive_locks_wait SIGNAL go';
|
|
--send drop table t1,t2
|
|
|
|
connection con1;
|
|
--echo connection: con1
|
|
--reap
|
|
|
|
connection default;
|
|
--echo connection: default
|
|
unlock tables;
|
|
|
|
connection con2;
|
|
--echo connection: con2
|
|
--error ER_BAD_TABLE_ERROR
|
|
--reap
|
|
|
|
connection default;
|
|
drop table t3;
|
|
|
|
disconnect con1;
|
|
disconnect con2;
|
|
disconnect con3;
|
|
|
|
# Clean up resources used in this test case.
|
|
--disable_warnings
|
|
SET DEBUG_SYNC= 'RESET';
|
|
--enable_warnings
|