1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

cleanup: THD::abort_current_cond_wait()

* reuse the loop in THD::abort_current_cond_wait, don't duplicate it
* find_thread_by_id should return whatever it has found, it's the
  caller's task not to kill COM_DAEMON (if the caller's a killer)

and other minor changes
This commit is contained in:
Sergei Golubchik
2021-02-05 15:00:38 +01:00
parent cbbcc8fa2b
commit 259a1902a0
7 changed files with 34 additions and 87 deletions

View File

@@ -49,9 +49,6 @@
#include <m_ctype.h>
#include <sys/stat.h>
#include <thr_alarm.h>
#ifdef __WIN__0
#include <io.h>
#endif
#include <mysys_err.h>
#include <limits.h>
@@ -70,6 +67,8 @@
#ifdef WITH_WSREP
#include "wsrep_thd.h"
#include "wsrep_trans_observer.h"
#else
static inline bool wsrep_is_bf_aborted(THD* thd) { return false; }
#endif /* WITH_WSREP */
#include "opt_trace.h"
@@ -1902,15 +1901,21 @@ void THD::awake_no_mutex(killed_state state_to_set)
}
/* Interrupt target waiting inside a storage engine. */
if (IF_WSREP(state_to_set != NOT_KILLED && !wsrep_is_bf_aborted(this),
state_to_set != NOT_KILLED))
if (state_to_set != NOT_KILLED && !wsrep_is_bf_aborted(this))
ha_kill_query(this, thd_kill_level(this));
/* Broadcast a condition to kick the target if it is waiting on it. */
abort_current_cond_wait(false);
DBUG_VOID_RETURN;
}
/* Broadcast a condition to kick the target if it is waiting on it. */
void THD::abort_current_cond_wait(bool force)
{
mysql_mutex_assert_owner(&LOCK_thd_kill);
if (mysys_var)
{
mysql_mutex_lock(&mysys_var->mutex);
if (!system_thread) // Don't abort locks
if (!system_thread || force) // Don't abort locks
mysys_var->abort=1;
/*
@@ -1968,7 +1973,6 @@ void THD::awake_no_mutex(killed_state state_to_set)
}
mysql_mutex_unlock(&mysys_var->mutex);
}
DBUG_VOID_RETURN;
}
@@ -2022,16 +2026,7 @@ bool THD::notify_shared_lock(MDL_context_owner *ctx_in_use,
mysql_mutex_lock(&in_use->LOCK_thd_kill);
if (in_use->killed < KILL_CONNECTION)
in_use->set_killed_no_mutex(KILL_CONNECTION);
if (in_use->mysys_var)
{
mysql_mutex_lock(&in_use->mysys_var->mutex);
if (in_use->mysys_var->current_cond)
mysql_cond_broadcast(in_use->mysys_var->current_cond);
/* Abort if about to wait in thr_upgrade_write_delay_lock */
in_use->mysys_var->abort= 1;
mysql_mutex_unlock(&in_use->mysys_var->mutex);
}
in_use->abort_current_cond_wait(true);
mysql_mutex_unlock(&in_use->LOCK_thd_kill);
signalled= TRUE;
}