1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-05 13:16:09 +03:00

Merge branch '10.11' into 11.0

This commit is contained in:
Oleksandr Byelkin
2024-01-30 08:54:10 +01:00
193 changed files with 6186 additions and 1673 deletions

View File

@@ -2124,7 +2124,6 @@ dispatch_command_return dispatch_command(enum enum_server_command command, THD *
{
ulong pos;
ushort flags;
uint32 slave_server_id;
status_var_increment(thd->status_var.com_other);
@@ -2135,10 +2134,26 @@ dispatch_command_return dispatch_command(enum enum_server_command command, THD *
/* TODO: The following has to be changed to an 8 byte integer */
pos = uint4korr(packet);
flags = uint2korr(packet + 4);
thd->variables.server_id=0; /* avoid suicide */
if ((slave_server_id= uint4korr(packet+6))) // mysqlbinlog.server_id==0
kill_zombie_dump_threads(slave_server_id);
thd->variables.server_id = slave_server_id;
if ((thd->variables.server_id= uint4korr(packet+6)))
{
bool got_error;
got_error= kill_zombie_dump_threads(thd,
thd->variables.server_id);
if (got_error || thd->killed)
{
if (!thd->killed)
my_printf_error(ER_MASTER_FATAL_ERROR_READING_BINLOG,
"Could not start dump thread for slave: %u as "
"it has already a running dump thread",
MYF(0), (uint) thd->variables.server_id);
else if (! thd->get_stmt_da()->is_set())
thd->send_kill_message();
error= TRUE;
thd->unregister_slave(); // todo: can be extraneous
break;
}
}
const char *name= packet + 10;
size_t nlen= strlen(name);
@@ -2146,6 +2161,8 @@ dispatch_command_return dispatch_command(enum enum_server_command command, THD *
general_log_print(thd, command, "Log: '%s' Pos: %lu", name, pos);
if (nlen < FN_REFLEN)
mysql_binlog_send(thd, thd->strmake(name, nlen), (my_off_t)pos, flags);
if (thd->killed && ! thd->get_stmt_da()->is_set())
thd->send_kill_message();
thd->unregister_slave(); // todo: can be extraneous
/* fake COM_QUIT -- if we get here, the thread needs to terminate */
error = TRUE;
@@ -9329,11 +9346,13 @@ kill_one_thread(THD *thd, my_thread_id id, killed_state kill_signal, killed_type
struct kill_threads_callback_arg
{
kill_threads_callback_arg(THD *thd_arg, LEX_USER *user_arg):
thd(thd_arg), user(user_arg) {}
kill_threads_callback_arg(THD *thd_arg, LEX_USER *user_arg,
killed_state kill_signal_arg):
thd(thd_arg), user(user_arg), kill_signal(kill_signal_arg), counter(0) {}
THD *thd;
LEX_USER *user;
List<THD> threads_to_kill;
killed_state kill_signal;
uint counter;
};
@@ -9356,11 +9375,12 @@ static my_bool kill_threads_callback(THD *thd, kill_threads_callback_arg *arg)
{
return MY_TEST(arg->thd->security_ctx->master_access & PROCESS_ACL);
}
if (!arg->threads_to_kill.push_back(thd, arg->thd->mem_root))
{
mysql_mutex_lock(&thd->LOCK_thd_kill); // Lock from delete
mysql_mutex_lock(&thd->LOCK_thd_data);
}
arg->counter++;
mysql_mutex_lock(&thd->LOCK_thd_kill); // Lock from delete
mysql_mutex_lock(&thd->LOCK_thd_data);
thd->awake_no_mutex(arg->kill_signal);
mysql_mutex_unlock(&thd->LOCK_thd_data);
mysql_mutex_unlock(&thd->LOCK_thd_kill);
}
}
return 0;
@@ -9370,42 +9390,17 @@ static my_bool kill_threads_callback(THD *thd, kill_threads_callback_arg *arg)
static uint kill_threads_for_user(THD *thd, LEX_USER *user,
killed_state kill_signal, ha_rows *rows)
{
kill_threads_callback_arg arg(thd, user);
kill_threads_callback_arg arg(thd, user, kill_signal);
DBUG_ENTER("kill_threads_for_user");
*rows= 0;
if (unlikely(thd->is_fatal_error)) // If we run out of memory
DBUG_RETURN(ER_OUT_OF_RESOURCES);
DBUG_PRINT("enter", ("user: %s signal: %u", user->user.str,
(uint) kill_signal));
*rows= 0;
if (server_threads.iterate(kill_threads_callback, &arg))
DBUG_RETURN(ER_KILL_DENIED_ERROR);
if (!arg.threads_to_kill.is_empty())
{
List_iterator_fast<THD> it2(arg.threads_to_kill);
THD *next_ptr;
THD *ptr= it2++;
do
{
ptr->awake_no_mutex(kill_signal);
/*
Careful here: The list nodes are allocated on the memroots of the
THDs to be awakened.
But those THDs may be terminated and deleted as soon as we release
LOCK_thd_kill, which will make the list nodes invalid.
Since the operation "it++" dereferences the "next" pointer of the
previous list node, we need to do this while holding LOCK_thd_kill.
*/
next_ptr= it2++;
mysql_mutex_unlock(&ptr->LOCK_thd_kill);
mysql_mutex_unlock(&ptr->LOCK_thd_data);
(*rows)++;
} while ((ptr= next_ptr));
}
*rows= arg.counter;
DBUG_RETURN(0);
}