Commit 85535259 authored by Sergey Vojtovich's avatar Sergey Vojtovich

MDEV-18400 - Move shutdown handling to main thread

Signal handler is now respoinsible for setting abort_loop and breaking
poll() in main thread. The rest is handled by main thread itself.

Removed redundant LOCK_error_log init/destroy wrappers.
Removed redundant unireg_end(): it is trivial and it has only one caller.
Removed unused ready_to_exit from PFS.
Removed kill_in_progress: duplicates abort_loop.
Removed shutdown_in_progress: duplicates abort_loop.
Removed ready_to_exit: was used to make sure main thread waits for
cleanups, which are now done by main thread itself.
Removed SIGNALS_DONT_BREAK_READ, MAYBE_BROKEN_SYSCALL,
kill_broken_server: never defined/used.
Make clean_up() static.
parent c2318291
...@@ -137,7 +137,7 @@ static int prepare_for_fill(TABLE_LIST *tables) ...@@ -137,7 +137,7 @@ static int prepare_for_fill(TABLE_LIST *tables)
*/ */
static bool going_down() static bool going_down()
{ {
return shutdown_plugin || shutdown_in_progress || (thd && thd->killed); return shutdown_plugin || abort_loop || (thd && thd->killed);
} }
/** /**
......
...@@ -17,6 +17,5 @@ ...@@ -17,6 +17,5 @@
#define INIT_INCLUDED #define INIT_INCLUDED
void unireg_init(ulong options); void unireg_init(ulong options);
void unireg_end(void);
#endif /* INIT_INCLUDED */ #endif /* INIT_INCLUDED */
This diff is collapsed.
...@@ -82,7 +82,7 @@ enum enum_slave_parallel_mode { ...@@ -82,7 +82,7 @@ enum enum_slave_parallel_mode {
}; };
/* Function prototypes */ /* Function prototypes */
void kill_mysql(THD *thd= 0); void kill_mysql(THD *thd);
void close_connection(THD *thd, uint sql_errno= 0); void close_connection(THD *thd, uint sql_errno= 0);
void handle_connection_in_main_thread(CONNECT *thd); void handle_connection_in_main_thread(CONNECT *thd);
void create_thread_to_handle_connection(CONNECT *connect); void create_thread_to_handle_connection(CONNECT *connect);
...@@ -770,8 +770,6 @@ enum enum_query_type ...@@ -770,8 +770,6 @@ enum enum_query_type
/* query_id */ /* query_id */
extern query_id_t global_query_id; extern query_id_t global_query_id;
void unireg_end(void);
/* increment query_id and return it. */ /* increment query_id and return it. */
inline __attribute__((warn_unused_result)) query_id_t next_query_id() inline __attribute__((warn_unused_result)) query_id_t next_query_id()
{ {
......
...@@ -1436,7 +1436,7 @@ bool Master_info_index::add_master_info(Master_info *mi, bool write_to_file) ...@@ -1436,7 +1436,7 @@ bool Master_info_index::add_master_info(Master_info *mi, bool write_to_file)
We have to protect against shutdown to ensure we are not calling We have to protect against shutdown to ensure we are not calling
my_hash_insert() while my_hash_free() is in progress my_hash_insert() while my_hash_free() is in progress
*/ */
if (unlikely(shutdown_in_progress) || if (unlikely(abort_loop) ||
!my_hash_insert(&master_info_hash, (uchar*) mi)) !my_hash_insert(&master_info_hash, (uchar*) mi))
{ {
if (global_system_variables.log_warnings > 1) if (global_system_variables.log_warnings > 1)
...@@ -1579,7 +1579,7 @@ uint any_slave_sql_running(bool already_locked) ...@@ -1579,7 +1579,7 @@ uint any_slave_sql_running(bool already_locked)
if (!already_locked) if (!already_locked)
mysql_mutex_lock(&LOCK_active_mi); mysql_mutex_lock(&LOCK_active_mi);
if (unlikely(shutdown_in_progress || !master_info_index)) if (unlikely(abort_loop || !master_info_index))
count= 1; count= 1;
else else
{ {
......
...@@ -184,8 +184,6 @@ extern char internal_table_name[2]; ...@@ -184,8 +184,6 @@ extern char internal_table_name[2];
extern char empty_c_string[1]; extern char empty_c_string[1];
extern MYSQL_PLUGIN_IMPORT const char **errmesg; extern MYSQL_PLUGIN_IMPORT const char **errmesg;
extern bool volatile shutdown_in_progress;
extern "C" LEX_STRING * thd_query_string (MYSQL_THD thd); extern "C" LEX_STRING * thd_query_string (MYSQL_THD thd);
extern "C" size_t thd_query_safe(MYSQL_THD thd, char *buf, size_t buflen); extern "C" size_t thd_query_safe(MYSQL_THD thd, char *buf, size_t buflen);
......
...@@ -2403,10 +2403,10 @@ void wsrep_kill_mysql(THD *thd) ...@@ -2403,10 +2403,10 @@ void wsrep_kill_mysql(THD *thd)
{ {
if (mysqld_server_started) if (mysqld_server_started)
{ {
if (!shutdown_in_progress) if (!abort_loop)
{ {
WSREP_INFO("starting shutdown"); WSREP_INFO("starting shutdown");
kill_mysql(); kill_mysql(thd);
} }
} }
else else
......
...@@ -24,8 +24,6 @@ ...@@ -24,8 +24,6 @@
struct sql_digest_storage; struct sql_digest_storage;
volatile bool ready_to_exit= false;
uint lower_case_table_names= 0; uint lower_case_table_names= 0;
CHARSET_INFO *files_charset_info= NULL; CHARSET_INFO *files_charset_info= NULL;
CHARSET_INFO *system_charset_info= NULL; CHARSET_INFO *system_charset_info= NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment