perfschema mdl related instrumentation changes

This commit is contained in:
Sergei Golubchik 2020-02-14 16:28:05 +01:00
parent 22b6d8487a
commit 05779bc6f1
25 changed files with 182 additions and 86 deletions

View File

@ -1006,7 +1006,7 @@ dbcontext::cmd_open(dbcallback_i& cb, const cmd_open_args& arg)
LEX_CSTRING db_name= { arg.dbn, strlen(arg.dbn) };
LEX_CSTRING tbl_name= { arg.tbl, strlen(arg.tbl) };
tables.init_one_table(&db_name, &tbl_name, 0, lock_type);
tables.mdl_request.init(MDL_key::TABLE, arg.dbn, arg.tbl,
MDL_REQUEST_INIT(&tables.mdl_request, MDL_key::TABLE, arg.dbn, arg.tbl,
for_write_flag ? MDL_SHARED_WRITE : MDL_SHARED_READ, MDL_TRANSACTION);
Open_table_context ot_act(thd, 0);
if (!open_table(thd, &tables, &ot_act)) {

View File

@ -161,7 +161,8 @@ static bool backup_start(THD *thd)
DBUG_RETURN(1);
}
mdl_request.init(MDL_key::BACKUP, "", "", MDL_BACKUP_START, MDL_EXPLICIT);
MDL_REQUEST_INIT(&mdl_request, MDL_key::BACKUP, "", "", MDL_BACKUP_START,
MDL_EXPLICIT);
if (thd->mdl_context.acquire_lock(&mdl_request,
thd->variables.lock_wait_timeout))
DBUG_RETURN(1);

View File

@ -121,6 +121,25 @@ static void init_debug_sync_psi_keys(void)
#endif /* HAVE_PSI_INTERFACE */
/**
Set the THD::proc_info without instrumentation.
This method is private to DEBUG_SYNC,
and on purpose avoid any use of:
- the SHOW PROFILE instrumentation
- the PERFORMANCE_SCHEMA instrumentation
so that using DEBUG_SYNC() in the server code
does not cause the instrumentations to record
spurious data.
*/
static const char*
debug_sync_thd_proc_info(THD *thd, const char* info)
{
const char* old_proc_info= thd->proc_info;
thd->proc_info= info;
return old_proc_info;
}
/**
Initialize the debug sync facility at server start.
@ -1365,7 +1384,7 @@ static void debug_sync_execute(THD *thd, st_debug_sync_action *action)
strxnmov(ds_control->ds_proc_info, sizeof(ds_control->ds_proc_info)-1,
"debug sync point: ", action->sync_point.c_ptr(), NullS);
old_proc_info= thd->proc_info;
thd_proc_info(thd, ds_control->ds_proc_info);
debug_sync_thd_proc_info(thd, ds_control->ds_proc_info);
}
/*
@ -1483,11 +1502,11 @@ static void debug_sync_execute(THD *thd, st_debug_sync_action *action)
mysql_mutex_lock(&thd->mysys_var->mutex);
thd->mysys_var->current_mutex= old_mutex;
thd->mysys_var->current_cond= old_cond;
thd_proc_info(thd, old_proc_info);
debug_sync_thd_proc_info(thd, old_proc_info);
mysql_mutex_unlock(&thd->mysys_var->mutex);
}
else
thd_proc_info(thd, old_proc_info);
debug_sync_thd_proc_info(thd, old_proc_info);
}
else
{

View File

@ -1489,7 +1489,8 @@ int ha_commit_trans(THD *thd, bool all)
We allow the owner of FTWRL to COMMIT; we assume that it knows
what it does.
*/
mdl_request.init(MDL_key::BACKUP, "", "", MDL_BACKUP_COMMIT, MDL_EXPLICIT);
MDL_REQUEST_INIT(&mdl_request, MDL_key::BACKUP, "", "", MDL_BACKUP_COMMIT,
MDL_EXPLICIT);
if (!WSREP(thd) &&
thd->mdl_context.acquire_lock(&mdl_request,

View File

@ -4027,7 +4027,7 @@ longlong Item_func_get_lock::val_int()
}
MDL_request ull_request;
ull_request.init(MDL_key::USER_LOCK, res->c_ptr_safe(), "",
MDL_REQUEST_INIT(&ull_request, MDL_key::USER_LOCK, res->c_ptr_safe(), "",
MDL_SHARED_NO_WRITE, MDL_EXPLICIT);
MDL_key *ull_key= &ull_request.key;

View File

@ -859,8 +859,10 @@ bool lock_schema_name(THD *thd, const char *db)
if (thd->has_read_only_protection())
return TRUE;
global_request.init(MDL_key::BACKUP, "", "", MDL_BACKUP_DDL, MDL_STATEMENT);
mdl_request.init(MDL_key::SCHEMA, db, "", MDL_EXCLUSIVE, MDL_TRANSACTION);
MDL_REQUEST_INIT(&global_request, MDL_key::BACKUP, "", "", MDL_BACKUP_DDL,
MDL_STATEMENT);
MDL_REQUEST_INIT(&mdl_request, MDL_key::SCHEMA, db, "", MDL_EXCLUSIVE,
MDL_TRANSACTION);
mdl_requests.push_front(&mdl_request);
mdl_requests.push_front(&global_request);
@ -917,10 +919,12 @@ bool lock_object_name(THD *thd, MDL_key::enum_mdl_namespace mdl_type,
if (thd->has_read_only_protection())
return TRUE;
global_request.init(MDL_key::BACKUP, "", "", MDL_BACKUP_DDL, MDL_STATEMENT);
schema_request.init(MDL_key::SCHEMA, db, "", MDL_INTENTION_EXCLUSIVE,
MDL_TRANSACTION);
mdl_request.init(mdl_type, db, name, MDL_EXCLUSIVE, MDL_TRANSACTION);
MDL_REQUEST_INIT(&global_request, MDL_key::BACKUP, "", "", MDL_BACKUP_DDL,
MDL_STATEMENT);
MDL_REQUEST_INIT(&schema_request, MDL_key::SCHEMA, db, "",
MDL_INTENTION_EXCLUSIVE, MDL_TRANSACTION);
MDL_REQUEST_INIT(&mdl_request, mdl_type, db, name, MDL_EXCLUSIVE,
MDL_TRANSACTION);
mdl_requests.push_front(&mdl_request);
mdl_requests.push_front(&schema_request);
@ -1041,7 +1045,7 @@ bool Global_read_lock::lock_global_read_lock(THD *thd)
MDL_BACKUP_FTWRL1));
DBUG_ASSERT(! thd->mdl_context.is_lock_owner(MDL_key::BACKUP, "", "",
MDL_BACKUP_FTWRL2));
mdl_request.init(MDL_key::BACKUP, "", "", MDL_BACKUP_FTWRL1,
MDL_REQUEST_INIT(&mdl_request, MDL_key::BACKUP, "", "", MDL_BACKUP_FTWRL1,
MDL_EXPLICIT);
do

View File

@ -25,6 +25,8 @@
#include <mysql/service_thd_wait.h>
#include <mysql/psi/mysql_stage.h>
#include <tpool.h>
#include <pfs_metadata_provider.h>
#include <mysql/psi/mysql_mdl.h>
static PSI_memory_key key_memory_MDL_context_acquire_locks;
@ -965,16 +967,20 @@ bool MDL_context::fix_pins()
@param mdl_type The MDL lock type for the request.
*/
void MDL_request::init(MDL_key::enum_mdl_namespace mdl_namespace,
void MDL_request::init_with_source(MDL_key::enum_mdl_namespace mdl_namespace,
const char *db_arg,
const char *name_arg,
enum_mdl_type mdl_type_arg,
enum_mdl_duration mdl_duration_arg)
enum_mdl_duration mdl_duration_arg,
const char *src_file,
uint src_line)
{
key.mdl_key_init(mdl_namespace, db_arg, name_arg);
type= mdl_type_arg;
duration= mdl_duration_arg;
ticket= NULL;
m_src_file= src_file;
m_src_line= src_line;
}
@ -987,14 +993,18 @@ void MDL_request::init(MDL_key::enum_mdl_namespace mdl_namespace,
@param mdl_type_arg The MDL lock type for the request.
*/
void MDL_request::init(const MDL_key *key_arg,
void MDL_request::init_by_key_with_source(const MDL_key *key_arg,
enum_mdl_type mdl_type_arg,
enum_mdl_duration mdl_duration_arg)
enum_mdl_duration mdl_duration_arg,
const char *src_file,
uint src_line)
{
key.mdl_key_init(key_arg);
type= mdl_type_arg;
duration= mdl_duration_arg;
ticket= NULL;
m_src_file= src_file;
m_src_line= src_line;
}
@ -1023,6 +1033,9 @@ MDL_ticket *MDL_ticket::create(MDL_context *ctx_arg, enum_mdl_type type_arg
void MDL_ticket::destroy(MDL_ticket *ticket)
{
mysql_mdl_destroy(ticket->m_psi);
ticket->m_psi= NULL;
delete ticket;
}
@ -2109,6 +2122,15 @@ MDL_context::try_acquire_lock_impl(MDL_request *mdl_request,
return TRUE;
}
DBUG_ASSERT(ticket->m_psi == NULL);
ticket->m_psi= mysql_mdl_create(ticket,
&mdl_request->key,
mdl_request->type,
mdl_request->duration,
MDL_ticket::PENDING,
mdl_request->m_src_file,
mdl_request->m_src_line);
ticket->m_lock= lock;
if (lock->can_grant_lock(mdl_request->type, this, false))
@ -2120,6 +2142,8 @@ MDL_context::try_acquire_lock_impl(MDL_request *mdl_request,
m_tickets[mdl_request->duration].push_front(ticket);
mdl_request->ticket= ticket;
mysql_mdl_set_status(ticket->m_psi, MDL_ticket::GRANTED);
}
else
*out_ticket= ticket;
@ -2169,6 +2193,15 @@ MDL_context::clone_ticket(MDL_request *mdl_request)
)))
return TRUE;
DBUG_ASSERT(ticket->m_psi == NULL);
ticket->m_psi= mysql_mdl_create(ticket,
&mdl_request->key,
mdl_request->type,
mdl_request->duration,
MDL_ticket::PENDING,
mdl_request->m_src_file,
mdl_request->m_src_line);
/* clone() is not supposed to be used to get a stronger lock. */
DBUG_ASSERT(mdl_request->ticket->has_stronger_or_equal_type(ticket->m_type));
@ -2181,6 +2214,8 @@ MDL_context::clone_ticket(MDL_request *mdl_request)
m_tickets[mdl_request->duration].push_front(ticket);
mysql_mdl_set_status(ticket->m_psi, MDL_ticket::GRANTED);
return FALSE;
}
@ -2320,6 +2355,12 @@ MDL_context::acquire_lock(MDL_request *mdl_request, double lock_wait_timeout)
mysql_prlock_unlock(&lock->m_rwlock);
PSI_metadata_locker_state state;
PSI_metadata_locker *locker= NULL;
if (ticket->m_psi != NULL)
locker= PSI_CALL_start_metadata_wait(&state, ticket->m_psi, __FILE__, __LINE__);
will_wait_for(ticket);
/* There is a shared or exclusive lock on the object. */
@ -2365,6 +2406,9 @@ MDL_context::acquire_lock(MDL_request *mdl_request, double lock_wait_timeout)
done_waiting_for();
if (locker != NULL)
PSI_CALL_end_metadata_wait(locker, 0);
if (wait_status != MDL_wait::GRANTED)
{
lock->remove_ticket(m_pins, &MDL_lock::m_waiting, ticket);
@ -2400,6 +2444,8 @@ MDL_context::acquire_lock(MDL_request *mdl_request, double lock_wait_timeout)
mdl_request->ticket= ticket;
mysql_mdl_set_status(ticket->m_psi, MDL_ticket::GRANTED);
DBUG_RETURN(FALSE);
}
@ -2531,8 +2577,8 @@ MDL_context::upgrade_shared_lock(MDL_ticket *mdl_ticket,
mdl_ticket->get_key()->mdl_namespace() != MDL_key::BACKUP)
DBUG_RETURN(FALSE);
mdl_xlock_request.init(&mdl_ticket->m_lock->key, new_type,
MDL_TRANSACTION);
MDL_REQUEST_INIT_BY_KEY(&mdl_xlock_request, &mdl_ticket->m_lock->key,
new_type, MDL_TRANSACTION);
if (acquire_lock(&mdl_xlock_request, lock_wait_timeout))
DBUG_RETURN(TRUE);
@ -2972,7 +3018,8 @@ MDL_context::is_lock_owner(MDL_key::enum_mdl_namespace mdl_namespace,
MDL_request mdl_request;
enum_mdl_duration not_unused;
/* We don't care about exact duration of lock here. */
mdl_request.init(mdl_namespace, db, name, mdl_type, MDL_TRANSACTION);
MDL_REQUEST_INIT(&mdl_request, mdl_namespace, db, name, mdl_type,
MDL_TRANSACTION);
MDL_ticket *ticket= find_ticket(&mdl_request, &not_unused);
DBUG_ASSERT(ticket == NULL || ticket->m_lock);

View File

@ -353,7 +353,7 @@ enum enum_mdl_duration {
or "name".
*/
class MDL_key
struct MDL_key
{
public:
#ifdef HAVE_PSI_INTERFACE
@ -535,18 +535,23 @@ public:
/** A lock is requested based on a fully qualified name and type. */
MDL_key key;
const char *m_src_file;
uint m_src_line;
public:
static void *operator new(size_t size, MEM_ROOT *mem_root) throw ()
{ return alloc_root(mem_root, size); }
static void operator delete(void *, MEM_ROOT *) {}
void init(MDL_key::enum_mdl_namespace namespace_arg,
void init_with_source(MDL_key::enum_mdl_namespace namespace_arg,
const char *db_arg, const char *name_arg,
enum_mdl_type mdl_type_arg,
enum_mdl_duration mdl_duration_arg);
void init(const MDL_key *key_arg, enum_mdl_type mdl_type_arg,
enum_mdl_duration mdl_duration_arg);
enum_mdl_duration mdl_duration_arg,
const char *src_file, uint src_line);
void init_by_key_with_source(const MDL_key *key_arg, enum_mdl_type mdl_type_arg,
enum_mdl_duration mdl_duration_arg,
const char *src_file, uint src_line);
/** Set type of lock request. Can be only applied to pending locks. */
inline void set_type(enum_mdl_type type_arg)
{
@ -610,6 +615,12 @@ public:
typedef void (*mdl_cached_object_release_hook)(void *);
#define MDL_REQUEST_INIT(R, P1, P2, P3, P4, P5) \
(*R).init_with_source(P1, P2, P3, P4, P5, __FILE__, __LINE__)
#define MDL_REQUEST_INIT_BY_KEY(R, P1, P2, P3) \
(*R).init_by_key_with_source(P1, P2, P3, __FILE__, __LINE__)
/**
An abstract class for inspection of a connected
@ -718,6 +729,11 @@ public:
/** Implement MDL_wait_for_subgraph interface. */
virtual bool accept_visitor(MDL_wait_for_graph_visitor *dvisitor);
virtual uint get_deadlock_weight() const;
/**
Status of lock request represented by the ticket as reflected in P_S.
*/
enum enum_psi_status { PENDING = 0, GRANTED,
PRE_ACQUIRE_NOTIFY, POST_RELEASE_NOTIFY };
private:
friend class MDL_context;
@ -731,9 +747,15 @@ private:
m_duration(duration_arg),
#endif
m_ctx(ctx_arg),
m_lock(NULL)
m_lock(NULL),
m_psi(NULL)
{}
virtual ~MDL_ticket()
{
DBUG_ASSERT(m_psi == NULL);
}
static MDL_ticket *create(MDL_context *ctx_arg, enum_mdl_type type_arg
#ifndef DBUG_OFF
, enum_mdl_duration duration_arg
@ -760,6 +782,8 @@ private:
*/
MDL_lock *m_lock;
PSI_metadata_lock *m_psi;
private:
MDL_ticket(const MDL_ticket &); /* not implemented */
MDL_ticket &operator=(const MDL_ticket &); /* not implemented */

View File

@ -1774,7 +1774,7 @@ bool lock_db_routines(THD *thd, const char *db)
sp_type);
if (!sph)
sph= &sp_handler_procedure;
mdl_request->init(sph->get_mdl_type(), db, sp_name,
MDL_REQUEST_INIT(mdl_request, sph->get_mdl_type(), db, sp_name,
MDL_EXCLUSIVE, MDL_TRANSACTION);
mdl_requests.push_front(mdl_request);
} while (! (nxtres= table->file->ha_index_next_same(table->record[0], keybuf, key_len)));
@ -2291,7 +2291,7 @@ bool sp_add_used_routine(Query_tables_list *prelocking_ctx, Query_arena *arena,
(Sroutine_hash_entry *)arena->alloc(sizeof(Sroutine_hash_entry));
if (unlikely(!rn)) // OOM. Error will be reported using fatal_error().
return FALSE;
rn->mdl_request.init(key, MDL_SHARED, MDL_TRANSACTION);
MDL_REQUEST_INIT_BY_KEY(&rn->mdl_request, key, MDL_SHARED, MDL_TRANSACTION);
if (my_hash_insert(&prelocking_ctx->sroutines, (uchar *)rn))
return FALSE;
prelocking_ctx->sroutines_list.link_in_list(rn, &rn->next);

View File

@ -4977,8 +4977,8 @@ sp_add_to_query_tables(THD *thd, LEX *lex,
table->lock_type= locktype;
table->select_lex= lex->current_select;
table->cacheable_table= 1;
table->mdl_request.init(MDL_key::TABLE, table->db.str, table->table_name.str,
mdl_type, MDL_TRANSACTION);
MDL_REQUEST_INIT(&table->mdl_request, MDL_key::TABLE, table->db.str,
table->table_name.str, mdl_type, MDL_TRANSACTION);
lex->add_to_query_tables(table);
return table;

View File

@ -122,9 +122,9 @@ static int prepare_for_repair(THD *thd, TABLE_LIST *table_list,
Let us try to open at least a .FRM for this table.
*/
table_list->mdl_request.init(MDL_key::TABLE,
table_list->db.str, table_list->table_name.str,
MDL_EXCLUSIVE, MDL_TRANSACTION);
MDL_REQUEST_INIT(&table_list->mdl_request, MDL_key::TABLE,
table_list->db.str, table_list->table_name.str,
MDL_EXCLUSIVE, MDL_TRANSACTION);
if (lock_table_names(thd, table_list, table_list->next_global,
thd->variables.lock_wait_timeout, 0))
@ -547,8 +547,9 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
close_thread_tables(thd);
table->table= NULL;
thd->mdl_context.release_transactional_locks();
table->mdl_request.init(MDL_key::TABLE, table->db.str, table->table_name.str,
MDL_SHARED_NO_READ_WRITE, MDL_TRANSACTION);
MDL_REQUEST_INIT(&table->mdl_request, MDL_key::TABLE, table->db.str,
table->table_name.str, MDL_SHARED_NO_READ_WRITE,
MDL_TRANSACTION);
}
#ifdef WITH_PARTITION_STORAGE_ENGINE
@ -822,8 +823,9 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
close_thread_tables(thd);
table->table= NULL;
thd->mdl_context.release_transactional_locks();
table->mdl_request.init(MDL_key::TABLE, table->db.str, table->table_name.str,
MDL_SHARED_NO_READ_WRITE, MDL_TRANSACTION);
MDL_REQUEST_INIT(&table->mdl_request, MDL_key::TABLE, table->db.str,
table->table_name.str, MDL_SHARED_NO_READ_WRITE,
MDL_TRANSACTION);
table->mdl_request.set_type(MDL_SHARED_READ);
table->lock_type= TL_READ;

View File

@ -437,7 +437,8 @@ bool close_cached_tables(THD *thd, TABLE_LIST *tables,
MDL_request *mdl_request= new (thd->mem_root) MDL_request;
if (mdl_request == NULL)
DBUG_RETURN(true);
mdl_request->init(&table->mdl_request.key, MDL_EXCLUSIVE, MDL_STATEMENT);
MDL_REQUEST_INIT_BY_KEY(mdl_request, &table->mdl_request.key,
MDL_EXCLUSIVE, MDL_STATEMENT);
mdl_requests.push_front(mdl_request);
}
@ -1577,10 +1578,9 @@ open_table_get_mdl_lock(THD *thd, Open_table_context *ot_ctx,
DBUG_ASSERT(!(flags & MYSQL_OPEN_FORCE_SHARED_MDL) ||
!(flags & MYSQL_OPEN_FORCE_SHARED_HIGH_PRIO_MDL));
mdl_request_shared.init(&mdl_request->key,
(flags & MYSQL_OPEN_FORCE_SHARED_MDL) ?
MDL_SHARED : MDL_SHARED_HIGH_PRIO,
MDL_TRANSACTION);
MDL_REQUEST_INIT_BY_KEY(&mdl_request_shared, &mdl_request->key,
flags & MYSQL_OPEN_FORCE_SHARED_MDL ? MDL_SHARED : MDL_SHARED_HIGH_PRIO,
MDL_TRANSACTION);
mdl_request= &mdl_request_shared;
}
@ -2151,8 +2151,8 @@ retry_share:
DBUG_RETURN(TRUE);
}
protection_request.init(MDL_key::BACKUP, "", "", mdl_type,
MDL_STATEMENT);
MDL_REQUEST_INIT(&protection_request, MDL_key::BACKUP, "", "", mdl_type,
MDL_STATEMENT);
/*
Install error handler which if possible will convert deadlock error
@ -4044,9 +4044,8 @@ lock_table_names(THD *thd, const DDL_options_st &options,
MDL_request *schema_request= new (thd->mem_root) MDL_request;
if (schema_request == NULL)
DBUG_RETURN(TRUE);
schema_request->init(MDL_key::SCHEMA, table->db.str, "",
MDL_INTENTION_EXCLUSIVE,
MDL_TRANSACTION);
MDL_REQUEST_INIT(schema_request, MDL_key::SCHEMA, table->db.str, "",
MDL_INTENTION_EXCLUSIVE, MDL_TRANSACTION);
mdl_requests.push_front(schema_request);
}
@ -4068,7 +4067,8 @@ lock_table_names(THD *thd, const DDL_options_st &options,
if (thd->has_read_only_protection())
DBUG_RETURN(true);
global_request.init(MDL_key::BACKUP, "", "", MDL_BACKUP_DDL, MDL_STATEMENT);
MDL_REQUEST_INIT(&global_request, MDL_key::BACKUP, "", "", MDL_BACKUP_DDL,
MDL_STATEMENT);
mdl_savepoint= thd->mdl_context.mdl_savepoint();
while (!thd->mdl_context.acquire_locks(&mdl_requests, lock_wait_timeout) &&

View File

@ -1148,9 +1148,9 @@ static bool find_db_tables_and_rm_known_files(THD *thd, MY_DIR *dirp,
(char*) table_list->table_name.str);
table_list->alias= table_list->table_name; // If lower_case_table_names=2
table_list->mdl_request.init(MDL_key::TABLE, table_list->db.str,
table_list->table_name.str, MDL_EXCLUSIVE,
MDL_TRANSACTION);
MDL_REQUEST_INIT(&table_list->mdl_request, MDL_key::TABLE,
table_list->db.str, table_list->table_name.str,
MDL_EXCLUSIVE, MDL_TRANSACTION);
/* Link into list */
(*tot_list_next_local)= table_list;
(*tot_list_next_global)= table_list;

View File

@ -333,8 +333,8 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, SQL_HANDLER *reopen)
right from the start as open_tables() can't handle properly
back-off for such locks.
*/
tables->mdl_request.init(MDL_key::TABLE, tables->db.str, tables->table_name.str,
MDL_SHARED_READ, MDL_TRANSACTION);
MDL_REQUEST_INIT(&tables->mdl_request, MDL_key::TABLE, tables->db.str,
tables->table_name.str, MDL_SHARED_READ, MDL_TRANSACTION);
mdl_savepoint= thd->mdl_context.mdl_savepoint();
/* for now HANDLER can be used only for real TABLES */

View File

@ -554,8 +554,8 @@ bool open_and_lock_for_insert_delayed(THD *thd, TABLE_LIST *table_list)
if (thd->has_read_only_protection())
DBUG_RETURN(TRUE);
protection_request.init(MDL_key::BACKUP, "", "", MDL_BACKUP_DML,
MDL_STATEMENT);
MDL_REQUEST_INIT(&protection_request, MDL_key::BACKUP, "", "",
MDL_BACKUP_DML, MDL_STATEMENT);
if (thd->mdl_context.acquire_lock(&protection_request,
thd->variables.lock_wait_timeout))
@ -2422,8 +2422,8 @@ bool delayed_get_table(THD *thd, MDL_request *grl_protection_request,
We need the tickets so that they can be cloned in
handle_delayed_insert
*/
di->grl_protection.init(MDL_key::BACKUP, "", "",
MDL_BACKUP_DML, MDL_STATEMENT);
MDL_REQUEST_INIT(&di->grl_protection, MDL_key::BACKUP, "", "",
MDL_BACKUP_DML, MDL_STATEMENT);
di->grl_protection.ticket= grl_protection_request->ticket;
init_mdl_requests(&di->table_list);
di->table_list.mdl_request.ticket= table_list->mdl_request.ticket;

View File

@ -8221,9 +8221,8 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd,
// Pure table aliases do not need to be locked:
if (ptr->db.str && !(table_options & TL_OPTION_ALIAS))
{
ptr->mdl_request.init(MDL_key::TABLE, ptr->db.str, ptr->table_name.str,
mdl_type,
MDL_TRANSACTION);
MDL_REQUEST_INIT(&ptr->mdl_request, MDL_key::TABLE, ptr->db.str,
ptr->table_name.str, mdl_type, MDL_TRANSACTION);
}
DBUG_RETURN(ptr);
}

View File

@ -452,10 +452,9 @@ int SEQUENCE::read_initial_values(TABLE *table)
where we don't have a mdl lock on the table
*/
mdl_request.init(MDL_key::TABLE,
table->s->db.str,
table->s->table_name.str,
MDL_SHARED_READ, MDL_EXPLICIT);
MDL_REQUEST_INIT(&mdl_request, MDL_key::TABLE, table->s->db.str,
table->s->table_name.str, MDL_SHARED_READ,
MDL_EXPLICIT);
mdl_requests.push_front(&mdl_request);
if (thd->mdl_context.acquire_locks(&mdl_requests,
thd->variables.lock_wait_timeout))

View File

@ -4769,8 +4769,9 @@ try_acquire_high_prio_shared_mdl_lock(THD *thd, TABLE_LIST *table,
bool can_deadlock)
{
bool error;
table->mdl_request.init(MDL_key::TABLE, table->db.str, table->table_name.str,
MDL_SHARED_HIGH_PRIO, MDL_TRANSACTION);
MDL_REQUEST_INIT(&table->mdl_request, MDL_key::TABLE, table->db.str,
table->table_name.str, MDL_SHARED_HIGH_PRIO,
MDL_TRANSACTION);
if (can_deadlock)
{

View File

@ -9205,8 +9205,8 @@ static bool fk_prepare_copy_alter_table(THD *thd, TABLE *table,
ref_table= tbuf;
}
mdl_request.init(MDL_key::TABLE, ref_db, ref_table, MDL_SHARED_NO_WRITE,
MDL_TRANSACTION);
MDL_REQUEST_INIT(&mdl_request, MDL_key::TABLE, ref_db, ref_table,
MDL_SHARED_NO_WRITE, MDL_TRANSACTION);
if (thd->mdl_context.acquire_lock(&mdl_request,
thd->variables.lock_wait_timeout))
DBUG_RETURN(true);
@ -9631,9 +9631,9 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db,
MDL_request_list mdl_requests;
MDL_request target_db_mdl_request;
target_mdl_request.init(MDL_key::TABLE,
alter_ctx.new_db.str, alter_ctx.new_name.str,
MDL_EXCLUSIVE, MDL_TRANSACTION);
MDL_REQUEST_INIT(&target_mdl_request, MDL_key::TABLE,
alter_ctx.new_db.str, alter_ctx.new_name.str,
MDL_EXCLUSIVE, MDL_TRANSACTION);
mdl_requests.push_front(&target_mdl_request);
/*
@ -9643,9 +9643,9 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db,
*/
if (alter_ctx.is_database_changed())
{
target_db_mdl_request.init(MDL_key::SCHEMA, alter_ctx.new_db.str, "",
MDL_INTENTION_EXCLUSIVE,
MDL_TRANSACTION);
MDL_REQUEST_INIT(&target_db_mdl_request, MDL_key::SCHEMA,
alter_ctx.new_db.str, "", MDL_INTENTION_EXCLUSIVE,
MDL_TRANSACTION);
mdl_requests.push_front(&target_db_mdl_request);
}

View File

@ -8222,11 +8222,10 @@ size_t max_row_length(TABLE *table, MY_BITMAP const *cols, const uchar *data)
void init_mdl_requests(TABLE_LIST *table_list)
{
for ( ; table_list ; table_list= table_list->next_global)
table_list->mdl_request.init(MDL_key::TABLE,
table_list->db.str, table_list->table_name.str,
table_list->lock_type >= TL_WRITE_ALLOW_WRITE ?
MDL_SHARED_WRITE : MDL_SHARED_READ,
MDL_TRANSACTION);
MDL_REQUEST_INIT(&table_list->mdl_request, MDL_key::TABLE,
table_list->db.str, table_list->table_name.str,
table_list->lock_type >= TL_WRITE_ALLOW_WRITE
? MDL_SHARED_WRITE : MDL_SHARED_READ, MDL_TRANSACTION);
}

View File

@ -2012,8 +2012,8 @@ struct TABLE_LIST
alias= (alias_arg ? *alias_arg : *table_name_arg);
lock_type= lock_type_arg;
updating= lock_type >= TL_WRITE_ALLOW_WRITE;
mdl_request.init(MDL_key::TABLE, db.str, table_name.str, mdl_type,
MDL_TRANSACTION);
MDL_REQUEST_INIT(&mdl_request, MDL_key::TABLE, db.str, table_name.str,
mdl_type, MDL_TRANSACTION);
}
TABLE_LIST(TABLE *table_arg, thr_lock_type lock_type)

View File

@ -592,7 +592,7 @@ bool trans_xa_commit(THD *thd)
We allow FLUSHer to COMMIT; we assume FLUSHer knows what it does.
*/
mdl_request.init(MDL_key::BACKUP, "", "", MDL_BACKUP_COMMIT,
MDL_REQUEST_INIT(&mdl_request, MDL_key::BACKUP, "", "", MDL_BACKUP_COMMIT,
MDL_TRANSACTION);
if (thd->mdl_context.acquire_lock(&mdl_request,

View File

@ -844,7 +844,7 @@ is_unaccessible:
mutex_exit(&dict_sys.mutex);
{
MDL_request request;
request.init(MDL_key::TABLE, db_buf, tbl_buf, MDL_SHARED, MDL_EXPLICIT);
MDL_REQUEST_INIT(&request,MDL_key::TABLE, db_buf, tbl_buf, MDL_SHARED, MDL_EXPLICIT);
if (trylock
? mdl_context->try_acquire_lock(&request)
: mdl_context->acquire_lock(&request,

View File

@ -997,7 +997,7 @@ long long spider_copy_tables_body(
#if MYSQL_VERSION_ID < 50500
if (open_and_lock_tables(thd, table_list))
#else
table_list->mdl_request.init(
MDL_REQUEST_INIT(&table_list->mdl_request,
MDL_key::TABLE,
SPIDER_TABLE_LIST_db_str(table_list),
SPIDER_TABLE_LIST_table_name_str(table_list),

View File

@ -1751,7 +1751,7 @@ long long spider_direct_sql_body(
SPIDER_TABLE_LIST_table_name_length(&table_list),
SPIDER_TABLE_LIST_table_name_str(&table_list), TL_WRITE);
#endif
tables->mdl_request.init(MDL_key::TABLE,
MDL_REQUEST_INIT(&tables->mdl_request, MDL_key::TABLE,
SPIDER_TABLE_LIST_db_str(&table_list),
SPIDER_TABLE_LIST_table_name_str(&table_list),
MDL_SHARED_WRITE, MDL_TRANSACTION);