-
-
Notifications
You must be signed in to change notification settings - Fork 2k
MDEV-34848 Remove overhead from unnecessary MDL_context_owner inheritance #4808
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -114,9 +114,11 @@ class MDL_context_owner | |
| virtual THD* get_thd() = 0; | ||
|
|
||
| /** | ||
| @note This interface is kept for backward compatibility. | ||
| The MDL subsystem now uses THD* directly for better performance. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What kind of backward compatibility? No, please remove it altogether. |
||
| @see THD::notify_shared_lock() | ||
| */ | ||
| virtual bool notify_shared_lock(MDL_context_owner *in_use, | ||
| virtual bool notify_shared_lock(THD *in_use, | ||
kevdn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| bool needs_thr_lock_abort, | ||
| bool needs_non_slave_abort) = 0; | ||
| }; | ||
|
|
@@ -832,7 +834,7 @@ class MDL_wait | |
| bool set_status(enum_wait_status result_arg); | ||
| enum_wait_status get_status(); | ||
| void reset_status(); | ||
| enum_wait_status timed_wait(MDL_context_owner *owner, | ||
| enum_wait_status timed_wait(THD *owner, | ||
| struct timespec *abs_timeout, | ||
| bool signal_timeout, | ||
| const PSI_stage_info *wait_state_name); | ||
|
|
@@ -924,7 +926,7 @@ class MDL_context | |
| void release_explicit_locks(); | ||
| void rollback_to_savepoint(const MDL_savepoint &mdl_savepoint); | ||
|
|
||
| MDL_context_owner *get_owner() { return m_owner; } | ||
| THD *get_owner() { return m_owner; } | ||
|
|
||
| /** @pre Only valid if we started waiting for lock. */ | ||
| inline uint get_deadlock_weight() const | ||
|
|
@@ -938,7 +940,7 @@ class MDL_context | |
| already has received some signal or closed | ||
| signal slot. | ||
| */ | ||
| void init(MDL_context_owner *arg) { m_owner= arg; reset(); } | ||
| void init(THD *arg) { m_owner= arg; reset(); } | ||
| void reset() { m_deadlock_overweight= 0; } | ||
|
|
||
| void set_needs_thr_lock_abort(bool needs_thr_lock_abort) | ||
|
|
@@ -1019,7 +1021,7 @@ class MDL_context | |
| involved schemas and global intention exclusive lock. | ||
| */ | ||
| Ticket_list m_tickets[MDL_DURATION_END]; | ||
| MDL_context_owner *m_owner; | ||
| THD *m_owner; | ||
| /** | ||
| TRUE - if for this context we will break protocol and try to | ||
| acquire table-level locks while having only S lock on | ||
|
|
@@ -1059,7 +1061,7 @@ class MDL_context | |
| bool fix_pins(); | ||
|
|
||
| public: | ||
| THD *get_thd() const { return m_owner->get_thd(); } | ||
| THD *get_thd() const { return m_owner; } | ||
| bool has_explicit_locks(); | ||
| void find_deadlock(); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2232,41 +2232,40 @@ void THD::disconnect() | |
| } | ||
|
|
||
|
|
||
| bool THD::notify_shared_lock(MDL_context_owner *ctx_in_use, | ||
| bool THD::notify_shared_lock(THD *ctx_in_use, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please rename it to |
||
| bool needs_thr_lock_abort, | ||
| bool needs_non_slave_abort) | ||
| { | ||
| THD *in_use= ctx_in_use->get_thd(); | ||
| bool signalled= FALSE; | ||
| DBUG_ENTER("THD::notify_shared_lock"); | ||
| DBUG_PRINT("enter",("needs_thr_lock_abort: %d", needs_thr_lock_abort)); | ||
|
|
||
| enum killed_state kill_signal; | ||
| if (in_use->system_thread & SYSTEM_THREAD_DELAYED_INSERT) | ||
| if (ctx_in_use->system_thread & SYSTEM_THREAD_DELAYED_INSERT) | ||
| kill_signal= KILL_CONNECTION; | ||
| else if (needs_non_slave_abort && !in_use->slave_thread) | ||
| else if (needs_non_slave_abort && !ctx_in_use->slave_thread) | ||
| kill_signal= KILL_QUERY; | ||
| else | ||
| kill_signal= NOT_KILLED; | ||
| if (kill_signal != NOT_KILLED && !in_use->killed) | ||
| if (kill_signal != NOT_KILLED && !ctx_in_use->killed) | ||
| { | ||
| /* This code is similar to kill_delayed_threads() */ | ||
| DBUG_PRINT("info", ("kill delayed thread")); | ||
| mysql_mutex_lock(&in_use->LOCK_thd_kill); | ||
| if (in_use->killed < kill_signal) | ||
| in_use->set_killed_no_mutex(kill_signal); | ||
| in_use->abort_current_cond_wait(true); | ||
| mysql_mutex_unlock(&in_use->LOCK_thd_kill); | ||
| mysql_mutex_lock(&ctx_in_use->LOCK_thd_kill); | ||
| if (ctx_in_use->killed < kill_signal) | ||
| ctx_in_use->set_killed_no_mutex(kill_signal); | ||
| ctx_in_use->abort_current_cond_wait(true); | ||
| mysql_mutex_unlock(&ctx_in_use->LOCK_thd_kill); | ||
| signalled= TRUE; | ||
| } | ||
|
|
||
| if (needs_thr_lock_abort) | ||
| { | ||
| mysql_mutex_lock(&in_use->LOCK_thd_data); | ||
| mysql_mutex_lock(&ctx_in_use->LOCK_thd_data); | ||
| /* If not already dying */ | ||
| if (in_use->killed != KILL_CONNECTION_HARD) | ||
| if (ctx_in_use->killed != KILL_CONNECTION_HARD) | ||
| { | ||
| for (TABLE *thd_table= in_use->open_tables; | ||
| for (TABLE *thd_table= ctx_in_use->open_tables; | ||
| thd_table ; | ||
| thd_table= thd_table->next) | ||
| { | ||
|
|
@@ -2283,7 +2282,7 @@ bool THD::notify_shared_lock(MDL_context_owner *ctx_in_use, | |
| } | ||
| } | ||
| } | ||
| mysql_mutex_unlock(&in_use->LOCK_thd_data); | ||
| mysql_mutex_unlock(&ctx_in_use->LOCK_thd_data); | ||
| } | ||
| DBUG_RETURN(signalled); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4586,15 +4586,15 @@ class THD: public THD_count, /* this must be first */ | |
| @note This function does not wait for the thread to give away its | ||
| locks. Waiting is done outside for all threads at once. | ||
|
|
||
| @param ctx_in_use The MDL context owner (thread) to wake up. | ||
| @param ctx_in_use The THD to wake up. | ||
| @param needs_thr_lock_abort Indicates that to wake up thread | ||
| this call needs to abort its waiting | ||
| on table-level lock. | ||
|
|
||
| @retval TRUE if the thread was woken up | ||
| @retval FALSE otherwise. | ||
| */ | ||
| bool notify_shared_lock(MDL_context_owner *ctx_in_use, | ||
| bool notify_shared_lock(THD *ctx_in_use, | ||
kevdn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| bool needs_thr_lock_abort, | ||
| bool needs_non_slave_abort) override; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You claim that you de-virtualized |
||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.