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

Merge 10.11 into 11.0

This commit is contained in:
Marko Mäkelä
2024-03-28 10:51:36 +02:00
490 changed files with 14843 additions and 4704 deletions

View File

@@ -303,7 +303,8 @@ static TYPELIB tc_heuristic_recover_typelib=
};
const char *first_keyword= "first";
const char *my_localhost= "localhost", *delayed_user= "DELAYED";
const char *my_localhost= "localhost",
*delayed_user= "delayed", *slave_user= "<replication_slave>";
bool opt_large_files= sizeof(my_off_t) > 4;
static my_bool opt_autocommit; ///< for --autocommit command-line option
@@ -1567,15 +1568,12 @@ static void kill_thread(THD *thd)
/**
First shutdown everything but slave threads and binlog dump connections
*/
static my_bool kill_thread_phase_1(THD *thd, int *n_threads_awaiting_ack)
static my_bool kill_thread_phase_1(THD *thd, void *)
{
DBUG_PRINT("quit", ("Informing thread %ld that it's time to die",
(ulong) thd->thread_id));
if (thd->slave_thread || thd->is_binlog_dump_thread() ||
(shutdown_wait_for_slaves &&
repl_semisync_master.is_thd_awaiting_semisync_ack(thd) &&
++(*n_threads_awaiting_ack)))
if (thd->slave_thread || thd->is_binlog_dump_thread())
return 0;
if (DBUG_IF("only_kill_system_threads") && !thd->system_thread)
@@ -1773,29 +1771,18 @@ static void close_connections(void)
This will give the threads some time to gracefully abort their
statements and inform their clients that the server is about to die.
*/
int n_threads_awaiting_ack= 0;
server_threads.iterate(kill_thread_phase_1, &n_threads_awaiting_ack);
server_threads.iterate(kill_thread_phase_1);
/*
If we are waiting on any ACKs, delay killing the thread until either an ACK
is received or the timeout is hit.
Allow at max the number of sessions to await a timeout; however, if all
ACKs have been received in less iterations, then quit early
*/
if (shutdown_wait_for_slaves && repl_semisync_master.get_master_enabled())
{
int waiting_threads= repl_semisync_master.sync_get_master_wait_sessions();
if (waiting_threads)
sql_print_information("Delaying shutdown to await semi-sync ACK");
while (waiting_threads-- > 0)
repl_semisync_master.await_slave_reply();
repl_semisync_master.await_all_slave_replies(
"Delaying shutdown to await semi-sync ACK");
}
DBUG_EXECUTE_IF("delay_shutdown_phase_2_after_semisync_wait",
my_sleep(500000););
Events::deinit();
slave_prepare_for_shutdown();
ack_receiver.stop();
@@ -1816,8 +1803,7 @@ static void close_connections(void)
*/
DBUG_PRINT("info", ("THD_count: %u", THD_count::value()));
for (int i= 0; THD_count::connection_thd_count() - n_threads_awaiting_ack
&& i < 1000; i++)
for (int i= 0; THD_count::connection_thd_count() && i < 1000; i++)
{
if (DBUG_IF("only_kill_system_threads_no_loop"))
break;
@@ -1836,9 +1822,9 @@ static void close_connections(void)
#endif
/* All threads has now been aborted */
DBUG_PRINT("quit", ("Waiting for threads to die (count=%u)",
THD_count::connection_thd_count() - n_threads_awaiting_ack));
THD_count::connection_thd_count()));
while (THD_count::connection_thd_count() - n_threads_awaiting_ack)
while (THD_count::connection_thd_count())
{
if (DBUG_IF("only_kill_system_threads_no_loop"))
break;
@@ -3223,7 +3209,6 @@ pthread_handler_t signal_hand(void *arg __attribute__((unused)))
sigset_t set;
int sig;
my_thread_init(); // Init new thread
DBUG_ENTER("signal_hand");
signal_thread_in_use= 1;
/*
@@ -3277,7 +3262,6 @@ pthread_handler_t signal_hand(void *arg __attribute__((unused)))
{
DBUG_PRINT("quit",("signal_handler: calling my_thread_end()"));
my_thread_end();
DBUG_LEAVE; // Must match DBUG_ENTER()
signal_thread_in_use= 0;
pthread_exit(0); // Safety
return 0; // Avoid compiler warnings
@@ -3795,20 +3779,35 @@ static void my_malloc_size_cb_func(long long size, my_bool is_thread_specific)
thd->status_var.local_memory_used > (int64)thd->variables.max_mem_used &&
likely(!thd->killed) && !thd->get_stmt_da()->is_set())
{
/* Ensure we don't get called here again */
char buf[50], *buf2;
thd->set_killed(KILL_QUERY);
my_snprintf(buf, sizeof(buf), "--max-session-mem-used=%llu",
thd->variables.max_mem_used);
if ((buf2= (char*) thd->alloc(256)))
{
my_snprintf(buf2, 256, ER_THD(thd, ER_OPTION_PREVENTS_STATEMENT), buf);
thd->set_killed(KILL_QUERY, ER_OPTION_PREVENTS_STATEMENT, buf2);
}
else
{
thd->set_killed(KILL_QUERY, ER_OPTION_PREVENTS_STATEMENT,
"--max-session-mem-used");
/*
Ensure we don't get called here again.
It is not safe to wait for LOCK_thd_kill here, as we could be called
from almost any context. For example while LOCK_plugin is being held;
but THD::awake() locks LOCK_thd_kill and LOCK_plugin in the opposite
order (MDEV-33443).
So ignore the max_mem_used limit in the unlikely case we cannot obtain
LOCK_thd_kill here (the limit will be enforced on the next allocation).
*/
if (!mysql_mutex_trylock(&thd->LOCK_thd_kill)) {
char buf[50], *buf2;
thd->set_killed_no_mutex(KILL_QUERY);
my_snprintf(buf, sizeof(buf), "--max-session-mem-used=%llu",
thd->variables.max_mem_used);
if ((buf2= (char*) thd->alloc(256)))
{
my_snprintf(buf2, 256,
ER_THD(thd, ER_OPTION_PREVENTS_STATEMENT), buf);
thd->set_killed_no_mutex(KILL_QUERY,
ER_OPTION_PREVENTS_STATEMENT, buf2);
}
else
{
thd->set_killed_no_mutex(KILL_QUERY, ER_OPTION_PREVENTS_STATEMENT,
"--max-session-mem-used");
}
mysql_mutex_unlock(&thd->LOCK_thd_kill);
}
}
DBUG_ASSERT((longlong) thd->status_var.local_memory_used >= 0 ||
@@ -5005,9 +5004,9 @@ static int init_server_components()
proc_info_hook= set_thd_stage_info;
/*
Print source revision hash, as one of the first lines, if not the
first in error log, for troubleshooting and debugging purposes
*/
Print source revision hash, as one of the first lines, if not the
first in error log, for troubleshooting and debugging purposes
*/
if (!opt_help)
sql_print_information("Starting MariaDB %s source revision %s as process %lu",
server_version, SOURCE_REVISION, (ulong) getpid());
@@ -5035,6 +5034,19 @@ static int init_server_components()
xid_cache_init();
/*
Do not open binlong when doing bootstrap.
This ensures that rpl_load_gtid_slave_state() will not fail with an error
as the mysql schema does not yet exists.
This also ensures that we don't get an empty binlog file if the user has
log-bin in his config files.
*/
if (opt_bootstrap)
{
opt_bin_log= opt_bin_log_used= binlog_format_used= 0;
opt_log_slave_updates= 0;
}
/* need to configure logging before initializing storage engines */
if (!opt_bin_log_used && !WSREP_ON)
{