mirror of
https://github.com/MariaDB/server.git
synced 2025-07-27 18:02:13 +03:00
Merge 10.5 into 10.6
This commit is contained in:
@ -2239,6 +2239,7 @@ dispatch_command_return dispatch_command(enum enum_server_command command, THD *
|
||||
break;
|
||||
general_log_print(thd, command, NullS);
|
||||
status_var_increment(thd->status_var.com_stat[SQLCOM_SHOW_STATUS]);
|
||||
*current_global_status_var= global_status_var;
|
||||
calc_sum_of_all_status(current_global_status_var);
|
||||
if (!(uptime= (ulong) (thd->start_time - server_start_time)))
|
||||
queries_per_second1000= 0;
|
||||
@ -9090,10 +9091,9 @@ struct find_thread_callback_arg
|
||||
};
|
||||
|
||||
|
||||
my_bool find_thread_callback(THD *thd, find_thread_callback_arg *arg)
|
||||
static my_bool find_thread_callback(THD *thd, find_thread_callback_arg *arg)
|
||||
{
|
||||
if (thd->get_command() != COM_DAEMON &&
|
||||
arg->id == (arg->query_id ? thd->query_id : (longlong) thd->thread_id))
|
||||
if (arg->id == (arg->query_id ? thd->query_id : (longlong) thd->thread_id))
|
||||
{
|
||||
mysql_mutex_lock(&thd->LOCK_thd_kill); // Lock from delete
|
||||
arg->thd= thd;
|
||||
@ -9110,27 +9110,6 @@ THD *find_thread_by_id(longlong id, bool query_id)
|
||||
return arg.thd;
|
||||
}
|
||||
|
||||
#ifdef WITH_WSREP
|
||||
my_bool find_thread_with_thd_data_lock_callback(THD *thd, find_thread_callback_arg *arg)
|
||||
{
|
||||
if (thd->get_command() != COM_DAEMON &&
|
||||
arg->id == (arg->query_id ? thd->query_id : (longlong) thd->thread_id))
|
||||
{
|
||||
if (WSREP(thd)) mysql_mutex_lock(&thd->LOCK_thd_data);
|
||||
mysql_mutex_lock(&thd->LOCK_thd_kill); // Lock from delete
|
||||
arg->thd= thd;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
THD *find_thread_by_id_with_thd_data_lock(longlong id, bool query_id)
|
||||
{
|
||||
find_thread_callback_arg arg(id, query_id);
|
||||
server_threads.iterate(find_thread_with_thd_data_lock_callback, &arg);
|
||||
return arg.thd;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
kill one thread.
|
||||
|
||||
@ -9147,11 +9126,11 @@ kill_one_thread(THD *thd, longlong id, killed_state kill_signal, killed_type typ
|
||||
uint error= (type == KILL_TYPE_QUERY ? ER_NO_SUCH_QUERY : ER_NO_SUCH_THREAD);
|
||||
DBUG_ENTER("kill_one_thread");
|
||||
DBUG_PRINT("enter", ("id: %lld signal: %u", id, (uint) kill_signal));
|
||||
#ifdef WITH_WSREP
|
||||
if (id && (tmp= find_thread_by_id_with_thd_data_lock(id, type == KILL_TYPE_QUERY)))
|
||||
#else
|
||||
if (id && (tmp= find_thread_by_id(id, type == KILL_TYPE_QUERY)))
|
||||
#endif
|
||||
tmp= find_thread_by_id(id, type == KILL_TYPE_QUERY);
|
||||
if (!tmp)
|
||||
DBUG_RETURN(error);
|
||||
|
||||
if (tmp->get_command() != COM_DAEMON)
|
||||
{
|
||||
/*
|
||||
If we're SUPER, we can KILL anything, including system-threads.
|
||||
@ -9174,6 +9153,7 @@ kill_one_thread(THD *thd, longlong id, killed_state kill_signal, killed_type typ
|
||||
faster and do a harder kill than KILL_SYSTEM_THREAD;
|
||||
*/
|
||||
|
||||
mysql_mutex_lock(&tmp->LOCK_thd_data); // for various wsrep* checks below
|
||||
#ifdef WITH_WSREP
|
||||
if (((thd->security_ctx->master_access & PRIV_KILL_OTHER_USER_PROCESS) ||
|
||||
thd->security_ctx->user_matches(tmp->security_ctx)) &&
|
||||
@ -9195,8 +9175,8 @@ kill_one_thread(THD *thd, longlong id, killed_state kill_signal, killed_type typ
|
||||
else
|
||||
#endif /* WITH_WSREP */
|
||||
{
|
||||
WSREP_DEBUG("kill_one_thread %llu, victim: %llu wsrep_aborter %llu by signal %d",
|
||||
thd->thread_id, id, tmp->wsrep_aborter, kill_signal);
|
||||
WSREP_DEBUG("kill_one_thread %llu, victim: %llu wsrep_aborter %llu by signal %d",
|
||||
thd->thread_id, id, tmp->wsrep_aborter, kill_signal);
|
||||
tmp->awake_no_mutex(kill_signal);
|
||||
WSREP_DEBUG("victim: %llu taken care of", id);
|
||||
error= 0;
|
||||
@ -9205,11 +9185,9 @@ kill_one_thread(THD *thd, longlong id, killed_state kill_signal, killed_type typ
|
||||
else
|
||||
error= (type == KILL_TYPE_QUERY ? ER_KILL_QUERY_DENIED_ERROR :
|
||||
ER_KILL_DENIED_ERROR);
|
||||
#ifdef WITH_WSREP
|
||||
if (WSREP(tmp)) mysql_mutex_unlock(&tmp->LOCK_thd_data);
|
||||
#endif
|
||||
mysql_mutex_unlock(&tmp->LOCK_thd_kill);
|
||||
mysql_mutex_unlock(&tmp->LOCK_thd_data);
|
||||
}
|
||||
mysql_mutex_unlock(&tmp->LOCK_thd_kill);
|
||||
DBUG_PRINT("exit", ("%d", error));
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
@ -9256,8 +9234,8 @@ static my_bool kill_threads_callback(THD *thd, kill_threads_callback_arg *arg)
|
||||
return 1;
|
||||
if (!arg->threads_to_kill.push_back(thd, arg->thd->mem_root))
|
||||
{
|
||||
if (WSREP(thd)) mysql_mutex_lock(&thd->LOCK_thd_data);
|
||||
mysql_mutex_lock(&thd->LOCK_thd_kill); // Lock from delete
|
||||
mysql_mutex_lock(&thd->LOCK_thd_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -9300,7 +9278,7 @@ static uint kill_threads_for_user(THD *thd, LEX_USER *user,
|
||||
*/
|
||||
next_ptr= it2++;
|
||||
mysql_mutex_unlock(&ptr->LOCK_thd_kill);
|
||||
if (WSREP(ptr)) mysql_mutex_unlock(&ptr->LOCK_thd_data);
|
||||
mysql_mutex_unlock(&ptr->LOCK_thd_data);
|
||||
(*rows)++;
|
||||
} while ((ptr= next_ptr));
|
||||
}
|
||||
|
Reference in New Issue
Block a user