1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-07 00:04:31 +03:00

MDEV-27595 Backport SQL service, introduced by MDEV-19275.

The SQL SERVICE backported into the 10.4.
This commit is contained in:
Alexey Botchkov
2022-07-24 00:40:06 +04:00
parent f0fe23566b
commit 1fa196a559
30 changed files with 1843 additions and 413 deletions

View File

@@ -1508,6 +1508,16 @@ static void end_ssl();
#ifndef EMBEDDED_LIBRARY
extern Atomic_counter<uint32_t> local_connection_thread_count;
uint THD_count::connection_thd_count()
{
return value() -
binlog_dump_thread_count -
local_connection_thread_count;
}
/****************************************************************************
** Code to end mysqld
****************************************************************************/
@@ -1780,10 +1790,8 @@ static void close_connections(void)
*/
DBUG_PRINT("info", ("THD_count: %u", THD_count::value()));
for (int i= 0; (THD_count::value() - binlog_dump_thread_count -
n_threads_awaiting_ack) &&
i < 1000;
i++)
for (int i= 0; THD_count::connection_thd_count() - n_threads_awaiting_ack
&& i < 1000; i++)
my_sleep(20000);
if (global_system_variables.log_warnings)
@@ -1801,13 +1809,12 @@ static void close_connections(void)
THD_count::value() - binlog_dump_thread_count -
n_threads_awaiting_ack));
while (THD_count::value() - binlog_dump_thread_count -
n_threads_awaiting_ack)
while (THD_count::connection_thd_count() - n_threads_awaiting_ack)
my_sleep(1000);
/* Kill phase 2 */
server_threads.iterate(kill_thread_phase_2);
for (uint64 i= 0; THD_count::value(); i++)
for (uint64 i= 0; THD_count::connection_thd_count(); i++)
{
/*
This time the warnings are emitted within the loop to provide a
@@ -2570,7 +2577,7 @@ void close_connection(THD *thd, uint sql_errno)
if (sql_errno)
{
net_send_error(thd, sql_errno, ER_DEFAULT(sql_errno), NULL);
thd->protocol->net_send_error(thd, sql_errno, ER_DEFAULT(sql_errno), NULL);
thd->print_aborted_warning(lvl, ER_DEFAULT(sql_errno));
}
else if (!thd->main_security_ctx.user)
@@ -5225,6 +5232,7 @@ static int init_server_components()
init_global_table_stats();
init_global_index_stats();
init_update_queries();
/* Allow storage engine to give real error messages */
if (unlikely(ha_init_errors()))
@@ -5470,7 +5478,6 @@ static int init_server_components()
ft_init_stopwords();
init_max_user_conn();
init_update_queries();
init_global_user_stats();
init_global_client_stats();
if (!opt_bootstrap)