mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Patch that changes metadata locking subsystem to use mutex per lock and
condition variable per context instead of one mutex and one conditional variable for the whole subsystem. This should increase concurrency in this subsystem. It also opens the way for further changes which are necessary to solve such bugs as bug #46272 "MySQL 5.4.4, new MDL: unnecessary deadlock" and bug #37346 "innodb does not detect deadlock between update and alter table". Two other notable changes done by this patch: - MDL subsystem no longer implicitly acquires global intention exclusive metadata lock when per-object metadata lock is acquired. Now this has to be done by explicit calls outside of MDL subsystem. - Instead of using separate MDL_context for opening system tables/tables for purposes of I_S we now create MDL savepoint in the main context before opening tables and rollback to this savepoint after closing them. This means that it is now possible to get ER_LOCK_DEADLOCK error even not inside a transaction. This might happen in unlikely case when one runs DDL on one of system tables while also running DDL on some other tables. Cases when this ER_LOCK_DEADLOCK error is not justified will be addressed by advanced deadlock detector for MDL subsystem which we plan to implement.
This commit is contained in:
@ -2871,7 +2871,7 @@ make_table_name_list(THD *thd, List<LEX_STRING> *table_names, LEX *lex,
|
||||
due to metadata locks, so to avoid
|
||||
them we should not wait in case if
|
||||
conflicting lock is present.
|
||||
@param[in] open_tables_state_backup pointer to Open_tables_state object
|
||||
@param[in] open_tables_state_backup pointer to Open_tables_backup object
|
||||
which is used to save|restore original
|
||||
status of variables related to
|
||||
open tables state
|
||||
@ -2885,7 +2885,7 @@ static int
|
||||
fill_schema_show_cols_or_idxs(THD *thd, TABLE_LIST *tables,
|
||||
ST_SCHEMA_TABLE *schema_table,
|
||||
bool can_deadlock,
|
||||
Open_tables_state *open_tables_state_backup)
|
||||
Open_tables_backup *open_tables_state_backup)
|
||||
{
|
||||
LEX *lex= thd->lex;
|
||||
bool res;
|
||||
@ -2941,7 +2941,8 @@ fill_schema_show_cols_or_idxs(THD *thd, TABLE_LIST *tables,
|
||||
table, res, db_name,
|
||||
table_name));
|
||||
thd->temporary_tables= 0;
|
||||
close_tables_for_reopen(thd, &show_table_list, NULL);
|
||||
close_tables_for_reopen(thd, &show_table_list,
|
||||
open_tables_state_backup->mdl_system_tables_svp);
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
@ -3236,8 +3237,12 @@ end_share:
|
||||
|
||||
end_unlock:
|
||||
pthread_mutex_unlock(&LOCK_open);
|
||||
/*
|
||||
Don't release the MDL lock, it can be part of a transaction.
|
||||
If it is not, it will be released by the call to
|
||||
MDL_context::rollback_to_savepoint() in the caller.
|
||||
*/
|
||||
|
||||
thd->mdl_context.release_lock(table_list.mdl_request.ticket);
|
||||
thd->clear_error();
|
||||
return res;
|
||||
}
|
||||
@ -3281,7 +3286,7 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
|
||||
COND *partial_cond= 0;
|
||||
uint derived_tables= lex->derived_tables;
|
||||
int error= 1;
|
||||
Open_tables_state open_tables_state_backup;
|
||||
Open_tables_backup open_tables_state_backup;
|
||||
bool save_view_prepare_mode= lex->view_prepare_mode;
|
||||
Query_tables_list query_tables_list_backup;
|
||||
#ifndef NO_EMBEDDED_ACCESS_CHECKS
|
||||
@ -3500,7 +3505,8 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
|
||||
res= schema_table->process_table(thd, show_table_list, table,
|
||||
res, &orig_db_name,
|
||||
&tmp_lex_string);
|
||||
close_tables_for_reopen(thd, &show_table_list, NULL);
|
||||
close_tables_for_reopen(thd, &show_table_list,
|
||||
open_tables_state_backup.mdl_system_tables_svp);
|
||||
}
|
||||
DBUG_ASSERT(!lex->query_tables_own_last);
|
||||
if (res)
|
||||
@ -4302,7 +4308,7 @@ int fill_schema_proc(THD *thd, TABLE_LIST *tables, COND *cond)
|
||||
TABLE *table= tables->table;
|
||||
bool full_access;
|
||||
char definer[USER_HOST_BUFF_SIZE];
|
||||
Open_tables_state open_tables_state_backup;
|
||||
Open_tables_backup open_tables_state_backup;
|
||||
DBUG_ENTER("fill_schema_proc");
|
||||
|
||||
strxmov(definer, thd->security_ctx->priv_user, "@",
|
||||
|
Reference in New Issue
Block a user