mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +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:
@ -471,6 +471,7 @@ THD::THD()
|
||||
{
|
||||
ulong tmp;
|
||||
|
||||
mdl_context.init(this);
|
||||
/*
|
||||
Pass nominal parameters to init_alloc_root only to ensure that
|
||||
the destructor works OK in case of an error. The main_mem_root
|
||||
@ -1007,7 +1008,8 @@ void THD::cleanup(void)
|
||||
*/
|
||||
DBUG_ASSERT(open_tables == NULL);
|
||||
/* All HANDLERs must have been closed by now. */
|
||||
DBUG_ASSERT(mdl_context.lt_or_ha_sentinel() == NULL);
|
||||
DBUG_ASSERT(mdl_context.lt_or_ha_sentinel() == NULL ||
|
||||
global_read_lock);
|
||||
/*
|
||||
Due to the above assert, this is guaranteed to release *all* in
|
||||
this session.
|
||||
@ -3024,19 +3026,21 @@ bool Security_context::user_matches(Security_context *them)
|
||||
access to mysql.proc table to find definitions of stored routines.
|
||||
****************************************************************************/
|
||||
|
||||
void THD::reset_n_backup_open_tables_state(Open_tables_state *backup)
|
||||
void THD::reset_n_backup_open_tables_state(Open_tables_backup *backup)
|
||||
{
|
||||
DBUG_ENTER("reset_n_backup_open_tables_state");
|
||||
backup->set_open_tables_state(this);
|
||||
backup->mdl_system_tables_svp= mdl_context.mdl_savepoint();
|
||||
reset_open_tables_state(this);
|
||||
state_flags|= Open_tables_state::BACKUPS_AVAIL;
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
|
||||
void THD::restore_backup_open_tables_state(Open_tables_state *backup)
|
||||
void THD::restore_backup_open_tables_state(Open_tables_backup *backup)
|
||||
{
|
||||
DBUG_ENTER("restore_backup_open_tables_state");
|
||||
mdl_context.rollback_to_savepoint(backup->mdl_system_tables_svp);
|
||||
/*
|
||||
Before we will throw away current open tables state we want
|
||||
to be sure that it was properly cleaned up.
|
||||
@ -3046,7 +3050,6 @@ void THD::restore_backup_open_tables_state(Open_tables_state *backup)
|
||||
lock == 0 &&
|
||||
locked_tables_mode == LTM_NONE &&
|
||||
m_reprepare_observer == NULL);
|
||||
mdl_context.destroy();
|
||||
|
||||
set_open_tables_state(backup);
|
||||
DBUG_VOID_RETURN;
|
||||
|
Reference in New Issue
Block a user