1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

Merge branch '10.6' into 10.11

This commit is contained in:
Oleksandr Byelkin
2024-01-30 08:17:58 +01:00
185 changed files with 6011 additions and 1647 deletions

View File

@ -2060,7 +2060,7 @@ send_event_to_slave(binlog_send_info *info, Log_event_type event_type,
}
if (need_sync && repl_semisync_master.flush_net(info->thd,
packet->c_ptr_safe()))
packet->c_ptr()))
{
info->error= ER_UNKNOWN_ERROR;
return "Failed to run hook 'after_send_event'";
@ -3011,8 +3011,13 @@ err:
if (info->thd->killed == KILL_SLAVE_SAME_ID)
{
info->errmsg= "A slave with the same server_uuid/server_id as this slave "
"has connected to the master";
/*
Note that the text is limited to 64 characters in errmsg-utf8 in
ER_ABORTING_CONNECTION.
*/
info->errmsg=
"A slave with the same server_uuid/server_id is already "
"connected";
info->error= ER_SLAVE_SAME_ID;
}
@ -3385,6 +3390,7 @@ int stop_slave(THD* thd, Master_info* mi, bool net_report )
@retval 0 success
@retval 1 error
*/
int reset_slave(THD *thd, Master_info* mi)
{
MY_STAT stat_area;
@ -3482,8 +3488,6 @@ int reset_slave(THD *thd, Master_info* mi)
else if (global_system_variables.log_warnings > 1)
sql_print_information("Deleted Master_info file '%s'.", fname);
if (rpl_semi_sync_slave_enabled)
repl_semisync_slave.reset_slave(mi);
err:
mi->unlock_slave_threads();
if (unlikely(error))
@ -3511,43 +3515,89 @@ err:
struct kill_callback_arg
{
kill_callback_arg(uint32 id): slave_server_id(id), thd(0) {}
uint32 slave_server_id;
kill_callback_arg(THD *thd_arg, uint32 id):
thd(thd_arg), slave_server_id(id), counter(0) {}
THD *thd;
uint32 slave_server_id;
uint counter;
};
static my_bool kill_callback(THD *thd, kill_callback_arg *arg)
/*
Collect all active dump threads
*/
static my_bool kill_callback_collect(THD *thd, kill_callback_arg *arg)
{
if (thd->get_command() == COM_BINLOG_DUMP &&
thd->variables.server_id == arg->slave_server_id)
thd->variables.server_id == arg->slave_server_id &&
thd != arg->thd)
{
arg->thd= thd;
arg->counter++;
mysql_mutex_lock(&thd->LOCK_thd_kill); // Lock from delete
mysql_mutex_lock(&thd->LOCK_thd_data);
return 1;
thd->awake_no_mutex(KILL_SLAVE_SAME_ID); // Mark killed
/*
Remover the thread from ack_receiver to ensure it is not
sending acks to the master anymore.
*/
ack_receiver.remove_slave(thd);
mysql_mutex_unlock(&thd->LOCK_thd_data);
mysql_mutex_unlock(&thd->LOCK_thd_kill);
}
return 0;
}
void kill_zombie_dump_threads(uint32 slave_server_id)
{
kill_callback_arg arg(slave_server_id);
server_threads.iterate(kill_callback, &arg);
/*
Check if there are any active dump threads
*/
if (arg.thd)
{
/*
Here we do not call kill_one_thread() as
it will be slow because it will iterate through the list
again. We just to do kill the thread ourselves.
*/
arg.thd->awake_no_mutex(KILL_SLAVE_SAME_ID);
mysql_mutex_unlock(&arg.thd->LOCK_thd_kill);
mysql_mutex_unlock(&arg.thd->LOCK_thd_data);
}
static my_bool kill_callback_check(THD *thd, kill_callback_arg *arg)
{
return (thd->get_command() == COM_BINLOG_DUMP &&
thd->variables.server_id == arg->slave_server_id &&
thd != arg->thd);
}
/**
Try to kill running dump threads on the master
@result 0 ok
@result 1 old slave thread exists and does not want to die
There should not be more than one dump thread with the same server id
this code has however in the past has several issues. To ensure that
things works in all cases (now and in the future), this code is collecting
all matching server id's and killing all of them.
*/
bool kill_zombie_dump_threads(THD *thd, uint32 slave_server_id)
{
kill_callback_arg arg(thd, slave_server_id);
server_threads.iterate(kill_callback_collect, &arg);
if (!arg.counter)
return 0;
/*
Wait up to SECONDS_TO_WAIT_FOR_DUMP_THREAD_KILL for kill
of all dump thread, trying every 1/10 of second.
*/
for (uint i= 10 * SECONDS_TO_WAIT_FOR_DUMP_THREAD_KILL ;
--i > 0 && !thd->killed;
i++)
{
if (!server_threads.iterate(kill_callback_check, &arg))
return 0; // All dump thread are killed
my_sleep(1000000L / 10); // Wait 1/10 of a second
}
return 1;
}
/**
Get value for a string parameter with error checking