mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Backport of:
---------------------------------------------------------- revno: 2617.69.20 committer: Konstantin Osipov <kostja@sun.com> branch nick: 5.4-4284-1-assert timestamp: Thu 2009-08-13 18:29:55 +0400 message: WL#4284 "Transactional DDL locking" A review fix. Since WL#4284 implementation separated MDL_request and MDL_ticket, MDL_request becamse a utility object necessary only to get a ticket. Store it by-value in TABLE_LIST with the intent to merge MDL_request::key with table_list->table_name and table_list->db in future. Change the MDL subsystem to not require MDL_requests to stay around till close_thread_tables(). Remove the list of requests from the MDL context. Requests for shared metadata locks acquired in open_tables() are only used as a list in recover_from_failed_open_table_attempt(), which calls mdl_context.wait_for_locks() for this list. To keep such list for recover_from_failed_open_table_attempt(), introduce a context class (Open_table_context), that collects all requests. A lot of minor cleanups and simplications that became possible with this change.
This commit is contained in:
@ -1180,6 +1180,49 @@ private:
|
||||
Internal_error_handler *m_err_handler;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
A context of open_tables() function, used to recover
|
||||
from a failed open_table() attempt.
|
||||
|
||||
Implemented in sql_base.cc.
|
||||
*/
|
||||
|
||||
class Open_table_context
|
||||
{
|
||||
public:
|
||||
enum enum_open_table_action
|
||||
{
|
||||
OT_NO_ACTION= 0,
|
||||
OT_WAIT,
|
||||
OT_DISCOVER,
|
||||
OT_REPAIR
|
||||
};
|
||||
Open_table_context(THD *thd);
|
||||
|
||||
bool recover_from_failed_open_table_attempt(THD *thd, TABLE_LIST *tables);
|
||||
bool request_backoff_action(enum_open_table_action action_arg);
|
||||
|
||||
void add_request(MDL_request *request)
|
||||
{ m_mdl_requests.push_front(request); }
|
||||
|
||||
bool can_recover_from_failed_open_table() const
|
||||
{ return m_action != OT_NO_ACTION; }
|
||||
bool can_deadlock() const { return m_can_deadlock; }
|
||||
private:
|
||||
/** List of requests for all locks taken so far. Used for waiting on locks. */
|
||||
MDL_request_list m_mdl_requests;
|
||||
/** Back off action. */
|
||||
enum enum_open_table_action m_action;
|
||||
/**
|
||||
Whether we had any locks when this context was created.
|
||||
If we did, they are from the previous statement of a transaction,
|
||||
and we can't safely do back-off (and release them).
|
||||
*/
|
||||
bool m_can_deadlock;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Tables that were locked with LOCK TABLES statement.
|
||||
|
||||
@ -1236,7 +1279,6 @@ public:
|
||||
}
|
||||
bool init_locked_tables(THD *thd);
|
||||
TABLE_LIST *locked_tables() { return m_locked_tables; }
|
||||
MEM_ROOT *locked_tables_root() { return &m_locked_tables_root; }
|
||||
void unlink_from_list(THD *thd, TABLE_LIST *table_list,
|
||||
bool remove_from_locked_tables);
|
||||
void unlink_all_closed_tables(THD *thd,
|
||||
@ -1895,15 +1937,6 @@ public:
|
||||
/* Debug Sync facility. See debug_sync.cc. */
|
||||
struct st_debug_sync_control *debug_sync_control;
|
||||
#endif /* defined(ENABLED_DEBUG_SYNC) */
|
||||
|
||||
/**
|
||||
Points to the memory root of Locked_tables_list if
|
||||
we're locking the tables for LOCK TABLES. Otherwise is NULL.
|
||||
This is necessary to ensure that metadata locks allocated for
|
||||
tables used in triggers will persist after statement end.
|
||||
*/
|
||||
MEM_ROOT *locked_tables_root;
|
||||
|
||||
THD();
|
||||
~THD();
|
||||
|
||||
|
Reference in New Issue
Block a user