diff options
author | Konstantin Osipov <kostja@sun.com> | 2009-12-02 19:15:40 +0300 |
---|---|---|
committer | Konstantin Osipov <kostja@sun.com> | 2009-12-02 19:15:40 +0300 |
commit | e3b3907c4f6f6dbfd650272e7c65880d04e5789e (patch) | |
tree | ff15b5d631f62066821c5a9b8436ecbc46bf7dec /sql/mdl.h | |
parent | b7e8b0164446432df2673b9bc628ac74c1b30b76 (diff) | |
download | mariadb-git-e3b3907c4f6f6dbfd650272e7c65880d04e5789e.tar.gz |
Backport of:
------------------------------------------------------------
revno: 2630.4.32
committer: Dmitry Lenev <dlenev@mysql.com>
branch nick: mysql-6.0-3726-w2
timestamp: Thu 2008-06-19 16:39:58 +0400
message:
WL#3726 "DDL locking for all metadata objects".
After-review fixes in progress.
Ensure that metadata locking subsystem properly handles
out-of-memory conditions. Clarified MDL interface by
separating release of locks and removal of lock requests
from the context.
sql/lock.cc:
mdl_release_lock(), mdl_acquire_exclusive_locks() and
mdl_try_acquire_exclusive_lock() are no longer responsible
for removal of metadata lock requests from the context.
One should explicitly call mdl_remove_all_locks() and
mdl_remove_lock() to do this.
sql/mdl.cc:
Ensured that metadata locking subsystem properly handles
out-of-memory conditions.
Introduced new MDL_INITIALIZED state for metadata lock
request which is used in all cases when lock is not acquired
and we have not associated request with object respesenting
lock.
MDL_PENDING is now only used for requests for exclusive locks
which are added to the MDL_LOCK::waiting_exclusive queue.
mdl_release_lock(), mdl_acquire_exclusive_locks() and
mdl_try_acquire_exclusive_lock() are no longer responsible
for removal of metadata lock requests from the context.
One should explicitly call mdl_remove_all_locks() and
newly introduced mdl_remove_lock() to do this.
Also renamed mdl_release_all_locks_for_name() to
emphasize that it also actually removes lock requests
from the context.
Finally mdl_try_acquire_exclusive_lock() is now returs
information about encountered lock conflict in separate
out parameter since its return value is used for distinguishing
between error (e.g. due to OOM) and success.
sql/mdl.h:
Introduced new MDL_INITIALIZED state for metadata lock
request which is used in all cases when lock is not acquired
and we have not associated request with object respesenting
lock.
MDL_PENDING is now only used for requests for exclusive locks
which are added to the MDL_LOCK::waiting_exclusive queue.
mdl_release_lock(), mdl_acquire_exclusive_locks() and
mdl_try_acquire_exclusive_lock() are no longer responsible
for removal of metadata lock requests from the context.
One should explicitly call mdl_remove_all_locks() and
newly introduced mdl_remove_lock() to do this.
Also renamed mdl_release_all_locks_for_name() to
emphasize that it also actually removes lock requests
from the context.
Finally mdl_try_acquire_exclusive_lock() is now returs
information about encountered lock conflict in separate
out parameter since its return value is used for distinguishing
between error (e.g. due to OOM) and success.
sql/sql_base.cc:
mdl_release_lock(), mdl_acquire_exclusive_locks() and mdl_try_acquire_exclusive_lock() are no longer responsible
for removal of metadata lock requests from the context.
One should explicitly call mdl_remove_all_locks() and
mdl_remove_lock() to do this.
Also adjusted open_table() to ensure that it
releases/removes metadata locks in case of error
after adding/acquiring them (unless keeping these
lock requests is required for recovering action).
sql/sql_delete.cc:
mdl_release_lock(), mdl_acquire_exclusive_locks() and mdl_try_acquire_exclusive_lock() are no longer responsible
for removal of metadata lock requests from the context.
One should explicitly call mdl_remove_all_locks() and
mdl_remove_lock() to do this.
sql/sql_handler.cc:
mdl_release_lock(), mdl_acquire_exclusive_locks() and mdl_try_acquire_exclusive_lock() are no longer responsible
for removal of metadata lock requests from the context.
One should explicitly call mdl_remove_all_locks() and
mdl_remove_lock() to do this.
sql/sql_show.cc:
mdl_release_lock(), mdl_acquire_exclusive_locks() and mdl_try_acquire_exclusive_lock() are no longer responsible
for removal of metadata lock requests from the context.
One should explicitly call mdl_remove_all_locks() and
mdl_remove_lock() to do this.
sql/sql_table.cc:
Renamed mdl_release_all_locks_for_name() to emphasize
that it also actually removes lock requests from the context.
mdl_release_lock(), mdl_acquire_exclusive_locks() and mdl_try_acquire_exclusive_lock() are no longer responsible
for removal of metadata lock requests from the context.
One should explicitly call mdl_remove_all_locks() and
mdl_remove_lock() to do this.
Finally mdl_try_acquire_exclusive_lock() is now returs
information about encountered lock conflict in separate
out parameter since its return value is used for distinguishing
between error (e.g. due to OOM) and success.
Diffstat (limited to 'sql/mdl.h')
-rw-r--r-- | sql/mdl.h | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/sql/mdl.h b/sql/mdl.h index b192980ebaa..92bd83038e5 100644 --- a/sql/mdl.h +++ b/sql/mdl.h @@ -44,7 +44,8 @@ enum enum_mdl_type {MDL_SHARED=0, MDL_SHARED_HIGH_PRIO, /** States which metadata lock request can have. */ -enum enum_mdl_state {MDL_PENDING=0, MDL_ACQUIRED, MDL_PENDING_UPGRADE}; +enum enum_mdl_state {MDL_INITIALIZED=0, MDL_PENDING, + MDL_ACQUIRED, MDL_PENDING_UPGRADE}; /** @@ -152,6 +153,7 @@ void mdl_init_lock(MDL_LOCK_DATA *lock_data, char *key, int type, MDL_LOCK_DATA *mdl_alloc_lock(int type, const char *db, const char *name, MEM_ROOT *root); void mdl_add_lock(MDL_CONTEXT *context, MDL_LOCK_DATA *lock_data); +void mdl_remove_lock(MDL_CONTEXT *context, MDL_LOCK_DATA *lock_data); void mdl_remove_all_locks(MDL_CONTEXT *context); /** @@ -160,7 +162,7 @@ void mdl_remove_all_locks(MDL_CONTEXT *context); inline void mdl_set_lock_type(MDL_LOCK_DATA *lock_data, enum_mdl_type lock_type) { - DBUG_ASSERT(lock_data->state == MDL_PENDING); + DBUG_ASSERT(lock_data->state == MDL_INITIALIZED); lock_data->type= lock_type; } @@ -170,14 +172,15 @@ bool mdl_acquire_exclusive_locks(MDL_CONTEXT *context); bool mdl_upgrade_shared_lock_to_exclusive(MDL_CONTEXT *context, MDL_LOCK_DATA *lock_data); bool mdl_try_acquire_exclusive_lock(MDL_CONTEXT *context, - MDL_LOCK_DATA *lock_data); + MDL_LOCK_DATA *lock_data, + bool *conflict); bool mdl_acquire_global_shared_lock(MDL_CONTEXT *context); bool mdl_wait_for_locks(MDL_CONTEXT *context); void mdl_release_locks(MDL_CONTEXT *context); -void mdl_release_all_locks_for_name(MDL_CONTEXT *context, - MDL_LOCK_DATA *lock_data); +void mdl_release_and_remove_all_locks_for_name(MDL_CONTEXT *context, + MDL_LOCK_DATA *lock_data); void mdl_release_lock(MDL_CONTEXT *context, MDL_LOCK_DATA *lock_data); void mdl_downgrade_exclusive_lock(MDL_CONTEXT *context, MDL_LOCK_DATA *lock_data); |