diff options
author | Jon Olav Hauglid <jon.hauglid@sun.com> | 2010-07-01 15:53:46 +0200 |
---|---|---|
committer | Jon Olav Hauglid <jon.hauglid@sun.com> | 2010-07-01 15:53:46 +0200 |
commit | 9ff272fbbd9f8e8bb412cf8ddc12d6e97242ef63 (patch) | |
tree | c9d08724cb81d3b7ffd2f6515930d6df9e4b5bf1 /sql/mdl.h | |
parent | 29e9130d60d79b88b9e6593a111ced4363e9225e (diff) | |
download | mariadb-git-9ff272fbbd9f8e8bb412cf8ddc12d6e97242ef63.tar.gz |
A 5.5 version of the fix for Bug #54360 "Deadlock DROP/ALTER/CREATE
DATABASE with open HANDLER"
Remove LOCK_create_db, database name locks, and use metadata locks instead.
This exposes CREATE/DROP/ALTER DATABASE statements to the graph-based
deadlock detector in MDL, and paves the way for a safe, deadlock-free
implementation of RENAME DATABASE.
Database DDL statements will now take exclusive metadata locks on
the database name, while table/view/routine DDL statements take
intention exclusive locks on the database name. This prevents race
conditions between database DDL and table/view/routine DDL.
(e.g. DROP DATABASE with concurrent CREATE/ALTER/DROP TABLE)
By adding database name locks, this patch implements
WL#4450 "DDL locking: CREATE/DROP DATABASE must use database locks" and
WL#4985 "DDL locking: namespace/hierarchical locks".
The patch also changes code to use init_one_table() where appropriate.
The new lock_table_names() function requires TABLE_LIST::db_length to
be set correctly, and this is taken care of by init_one_table().
This patch also adds a simple template to help work with
the mysys HASH data structure.
Most of the patch was written by Konstantin Osipov.
Diffstat (limited to 'sql/mdl.h')
-rw-r--r-- | sql/mdl.h | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/sql/mdl.h b/sql/mdl.h index ad3945f524c..5c58289aea2 100644 --- a/sql/mdl.h +++ b/sql/mdl.h @@ -40,15 +40,16 @@ class Deadlock_detection_visitor; Type of metadata lock request. @sa Comments for MDL_object_lock::can_grant_lock() and - MDL_global_lock::can_grant_lock() for details. + MDL_scoped_lock::can_grant_lock() for details. */ enum enum_mdl_type { /* - An intention exclusive metadata lock. Used only for global locks. + An intention exclusive metadata lock. Used only for scoped locks. Owner of this type of lock can acquire upgradable exclusive locks on individual objects. - Compatible with other IX locks, but is incompatible with global S lock. + Compatible with other IX locks, but is incompatible with scoped S and + X locks. */ MDL_INTENTION_EXCLUSIVE= 0, /* @@ -179,6 +180,7 @@ public: MDL_key is also used outside of the MDL subsystem. */ enum enum_mdl_namespace { GLOBAL=0, + SCHEMA, TABLE, FUNCTION, PROCEDURE, @@ -646,6 +648,8 @@ private: closes all open HANDLERs. However, one can open a few HANDLERs after entering the read only mode. + * LOCK TABLES locks include intention exclusive locks on + involved schemas. */ Ticket_list m_tickets; /** |