mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
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.
This commit is contained in:
@ -2208,7 +2208,8 @@ err:
|
||||
and locked and therefore have to remove several metadata lock
|
||||
requests associated with them.
|
||||
*/
|
||||
mdl_release_all_locks_for_name(&thd->mdl_context, table->mdl_lock_data);
|
||||
mdl_release_and_remove_all_locks_for_name(&thd->mdl_context,
|
||||
table->mdl_lock_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4080,13 +4081,27 @@ static bool lock_table_name_if_not_cached(THD *thd, const char *db,
|
||||
const char *table_name,
|
||||
MDL_LOCK_DATA **lock_data)
|
||||
{
|
||||
bool conflict;
|
||||
|
||||
if (!(*lock_data= mdl_alloc_lock(0, db, table_name, thd->mem_root)))
|
||||
return TRUE;
|
||||
mdl_set_lock_type(*lock_data, MDL_EXCLUSIVE);
|
||||
mdl_add_lock(&thd->mdl_context, *lock_data);
|
||||
if (mdl_try_acquire_exclusive_lock(&thd->mdl_context, *lock_data))
|
||||
if (mdl_try_acquire_exclusive_lock(&thd->mdl_context, *lock_data,
|
||||
&conflict))
|
||||
{
|
||||
*lock_data= 0;
|
||||
/*
|
||||
To simplify our life under LOCK TABLES we remove unsatisfied
|
||||
lock request from the context.
|
||||
*/
|
||||
mdl_remove_lock(&thd->mdl_context, *lock_data);
|
||||
if (!conflict)
|
||||
{
|
||||
/* Probably OOM. */
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
*lock_data= 0;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
@ -4157,7 +4172,10 @@ bool mysql_create_table(THD *thd, const char *db, const char *table_name,
|
||||
|
||||
unlock:
|
||||
if (target_lock_data)
|
||||
{
|
||||
mdl_release_lock(&thd->mdl_context, target_lock_data);
|
||||
mdl_remove_lock(&thd->mdl_context, target_lock_data);
|
||||
}
|
||||
pthread_mutex_lock(&LOCK_lock_db);
|
||||
if (!--creating_table && creating_database)
|
||||
pthread_cond_signal(&COND_refresh);
|
||||
@ -4416,7 +4434,10 @@ static int prepare_for_repair(THD *thd, TABLE_LIST *table_list,
|
||||
mdl_set_lock_type(mdl_lock_data, MDL_EXCLUSIVE);
|
||||
mdl_add_lock(&thd->mdl_context, mdl_lock_data);
|
||||
if (mdl_acquire_exclusive_locks(&thd->mdl_context))
|
||||
{
|
||||
mdl_remove_lock(&thd->mdl_context, mdl_lock_data);
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&LOCK_open);
|
||||
if (!(share= (get_table_share(thd, table_list, key, key_length, 0,
|
||||
@ -4550,7 +4571,10 @@ end:
|
||||
}
|
||||
/* In case of a temporary table there will be no metadata lock. */
|
||||
if (error && mdl_lock_data)
|
||||
{
|
||||
mdl_release_lock(&thd->mdl_context, mdl_lock_data);
|
||||
mdl_remove_lock(&thd->mdl_context, mdl_lock_data);
|
||||
}
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
@ -5518,7 +5542,10 @@ binlog:
|
||||
|
||||
err:
|
||||
if (target_lock_data)
|
||||
{
|
||||
mdl_release_lock(&thd->mdl_context, target_lock_data);
|
||||
mdl_remove_lock(&thd->mdl_context, target_lock_data);
|
||||
}
|
||||
DBUG_RETURN(res);
|
||||
}
|
||||
|
||||
@ -6876,7 +6903,9 @@ view_err:
|
||||
if (new_name != table_name || new_db != db)
|
||||
{
|
||||
mdl_release_lock(&thd->mdl_context, target_lock_data);
|
||||
mdl_release_all_locks_for_name(&thd->mdl_context, mdl_lock_data);
|
||||
mdl_remove_lock(&thd->mdl_context, target_lock_data);
|
||||
mdl_release_and_remove_all_locks_for_name(&thd->mdl_context,
|
||||
mdl_lock_data);
|
||||
}
|
||||
else
|
||||
mdl_downgrade_exclusive_lock(&thd->mdl_context, mdl_lock_data);
|
||||
@ -7554,7 +7583,9 @@ view_err:
|
||||
if ((new_name != table_name || new_db != db))
|
||||
{
|
||||
mdl_release_lock(&thd->mdl_context, target_lock_data);
|
||||
mdl_release_all_locks_for_name(&thd->mdl_context, mdl_lock_data);
|
||||
mdl_remove_lock(&thd->mdl_context, target_lock_data);
|
||||
mdl_release_and_remove_all_locks_for_name(&thd->mdl_context,
|
||||
mdl_lock_data);
|
||||
}
|
||||
else
|
||||
mdl_downgrade_exclusive_lock(&thd->mdl_context, mdl_lock_data);
|
||||
@ -7613,7 +7644,10 @@ err:
|
||||
thd->abort_on_warning= save_abort_on_warning;
|
||||
}
|
||||
if (target_lock_data)
|
||||
{
|
||||
mdl_release_lock(&thd->mdl_context, target_lock_data);
|
||||
mdl_remove_lock(&thd->mdl_context, target_lock_data);
|
||||
}
|
||||
DBUG_RETURN(TRUE);
|
||||
|
||||
err_with_mdl:
|
||||
@ -7625,8 +7659,11 @@ err_with_mdl:
|
||||
*/
|
||||
thd->locked_tables_list.unlink_all_closed_tables();
|
||||
if (target_lock_data)
|
||||
{
|
||||
mdl_release_lock(&thd->mdl_context, target_lock_data);
|
||||
mdl_release_all_locks_for_name(&thd->mdl_context, mdl_lock_data);
|
||||
mdl_remove_lock(&thd->mdl_context, target_lock_data);
|
||||
}
|
||||
mdl_release_and_remove_all_locks_for_name(&thd->mdl_context, mdl_lock_data);
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
/* mysql_alter_table */
|
||||
|
Reference in New Issue
Block a user