From c6024dfc4e09d5eed076230a8645a8f4dae0d2f8 Mon Sep 17 00:00:00 2001 From: Alexey Botchkov Date: Thu, 2 Sep 2010 23:37:04 +0500 Subject: Bug#53251 mysql_library_init fails on second execution with embedded library thread-specific variables weren't set when we load error message files. per-file comments: libmysqld/lib_sql.cc Bug#53251 mysql_library_init fails on second execution with embedded library we need to call my_thread_init() once more. Normally it's called at the my_init() stage but that doesn't happen on the second my_init() call. sql/derror.cc Bug#53251 mysql_library_init fails on second execution with embedded library use default errors for the embedded server. sql/mysqld.cc Bug#53251 mysql_library_init fails on second execution with embedded library unregister server errors in clean_up(). Without it the error list contains that on the second mysql_server_init() which is not good. sql/set_var.cc Bug#53251 mysql_library_init fails on second execution with embedded library sys_var::cleanup() call instead of the destructor sql/set_var.h Bug#53251 mysql_library_init fails on second execution with embedded library sys_var::cleanup() introduced instead of the destructor sql/sys_vars.h Bug#53251 mysql_library_init fails on second execution with embedded library Sys_var_charptr::cleanup() implemented --- sql/mysqld.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'sql/mysqld.cc') diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 6dd74eb299a..840616e0e7c 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1486,6 +1486,7 @@ void clean_up(bool print_message) cleanup_errmsgs(); MYSQL_CALLBACK(thread_scheduler, end, ()); finish_client_errs(); + (void) my_error_unregister(ER_ERROR_FIRST, ER_ERROR_LAST); // finish server errs DBUG_PRINT("quit", ("Error messages freed")); /* Tell main we are ready */ logger.cleanup_end(); -- cgit v1.2.1 From bb04ac973468b4fad94d9728240ef02b3e1c4dcd Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Thu, 9 Sep 2010 15:33:35 -0600 Subject: Bug#56324 Race Condition while shutting down MySQL: "PSI_server" Before this fix, the server could crash during shutdown, due to race conditions, that occured when killing the server. In particular, the performance schema instrumentation handle, PSI_server, and the performance schema itself would be cleaned up too soon, causing race conditions with a running kill server thread. The specifics of the race condition found are that: the main thread executing "PSI_server= NULL" can cause crashes in other threads still running, which are executing "if (PSI_server != NULL) PSI_server->xxx()" as part of the performance schema instrumentation. While the bug was reported for the kill server thread, in theory the same crash could happen with the signal thread, as found by code analysis. The correct fix would be to only shutdown the performance schema and set PSI_server to NULL after every other thread is guaranteed to be completed, including the kill_server_thread. However, due to the existing mysqld server design, this is not the case. See in particular bug number 56666. The work around used to fix this race condition is to simply not perform the call to shutdown_performance_schema() when the server exits, and to keep the PSI_server pointer unchanged. This will cause memory leaks to be reported by tools like valgrind, but no memory leak actually happen because the process is about to exit(). As a result, the file mysql-test/valgrind.supp has been updated to filter out these false positive messages. This code has been tested with running in a loop the following tests in parallel, which have been known to fail with race conditions in the past: - rpl_change_master - binlog_max_extension - events_restart - rpl_heartbeat_basic and no crash of test failure has been seen with the changed code. --- sql/mysqld.cc | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'sql/mysqld.cc') diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 6dd74eb299a..854d314d7d5 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1395,6 +1395,12 @@ static void mysqld_exit(int exit_code) mysql_audit_finalize(); clean_up_mutexes(); clean_up_error_log_mutex(); +#ifdef WITH_PERFSCHEMA_STORAGE_ENGINE + /* + Bug#56666 needs to be fixed before calling: + shutdown_performance_schema(); + */ +#endif my_end(opt_endinfo ? MY_CHECK_ERROR | MY_GIVE_INFO : 0); exit(exit_code); /* purecov: inspected */ } @@ -2732,6 +2738,11 @@ pthread_handler_t signal_hand(void *arg __attribute__((unused))) if (!abort_loop) { abort_loop=1; // mark abort for threads +#ifdef HAVE_PSI_INTERFACE + /* Delete the instrumentation for the signal thread */ + if (likely(PSI_server != NULL)) + PSI_server->delete_current_thread(); +#endif #ifdef USE_ONE_SIGNAL_HAND pthread_t tmp; if (mysql_thread_create(0, /* Not instrumented */ @@ -4587,6 +4598,15 @@ int mysqld_main(int argc, char **argv) #endif #endif /* __WIN__ */ +#ifdef HAVE_PSI_INTERFACE + /* + Disable the main thread instrumentation, + to avoid recording events during the shutdown. + */ + if (PSI_server) + PSI_server->delete_current_thread(); +#endif + /* Wait until cleanup is done */ mysql_mutex_lock(&LOCK_thread_count); while (!ready_to_exit) @@ -4604,18 +4624,6 @@ int mysqld_main(int argc, char **argv) } #endif clean_up(1); -#ifdef HAVE_PSI_INTERFACE - /* - Disable the instrumentation, to avoid recording events - during the shutdown. - */ - if (PSI_server) - { - PSI_server->delete_current_thread(); - PSI_server= NULL; - } - shutdown_performance_schema(); -#endif mysqld_exit(0); } -- cgit v1.2.1 From 40ee088f68a452ac2ed19622481c73d6d38c7ec3 Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Mon, 4 Oct 2010 08:52:59 -0300 Subject: Bug#57210: remove pstack Quoting from the bug report: The pstack library has been included in MySQL since version 4.0.0. It's useless and should be removed. Details: According to its own documentation, pstack only works on Linux on x86 in 32 bit mode and requires LinuxThreads and a statically linked binary. It doesn't really support any Linux from 2003 or later and doesn't work on any other OS. --- sql/mysqld.cc | 23 ----------------------- 1 file changed, 23 deletions(-) (limited to 'sql/mysqld.cc') diff --git a/sql/mysqld.cc b/sql/mysqld.cc index af98ed91adf..3e8f699bbd9 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -97,13 +97,6 @@ #define mysqld_charset &my_charset_latin1 -/* stack traces are only supported on linux intel */ -#if defined(__linux__) && defined(__i386__) && defined(USE_PSTACK) -#define HAVE_STACK_TRACE_ON_SEGV -#include "../pstack/pstack.h" -char pstack_file_name[80]; -#endif /* __linux__ */ - /* We have HAVE_purify below as this speeds up the shutdown of MySQL */ #if defined(HAVE_DEC_3_2_THREADS) || defined(SIGNALS_DONT_BREAK_READ) || defined(HAVE_purify) && defined(__linux__) @@ -650,9 +643,6 @@ char *opt_logname, *opt_slow_logname; /* Static variables */ static bool kill_in_progress, segfaulted; -#ifdef HAVE_STACK_TRACE_ON_SEGV -static my_bool opt_do_pstack; -#endif /* HAVE_STACK_TRACE_ON_SEGV */ static my_bool opt_bootstrap, opt_myisam_log; static int cleanup_done; static ulong opt_specialflag; @@ -2686,14 +2676,6 @@ pthread_handler_t signal_hand(void *arg __attribute__((unused))) if (!opt_bootstrap) create_pid_file(); -#ifdef HAVE_STACK_TRACE_ON_SEGV - if (opt_do_pstack) - { - sprintf(pstack_file_name,"mysqld-%lu-%%d-%%d.backtrace", (ulong)getpid()); - pstack_install_segv_action(pstack_file_name); - } -#endif /* HAVE_STACK_TRACE_ON_SEGV */ - /* signal to start_signal_handler that we are ready This works by waiting for start_signal_handler to free mutex, @@ -5740,11 +5722,6 @@ struct my_option my_long_options[]= &disconnect_slave_event_count, &disconnect_slave_event_count, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif /* HAVE_REPLICATION */ -#ifdef HAVE_STACK_TRACE_ON_SEGV - {"enable-pstack", 0, "Print a symbolic stack trace on failure.", - &opt_do_pstack, &opt_do_pstack, 0, GET_BOOL, NO_ARG, 0, 0, - 0, 0, 0, 0}, -#endif /* HAVE_STACK_TRACE_ON_SEGV */ {"exit-info", 'T', "Used for debugging. Use at your own risk.", 0, 0, 0, GET_LONG, OPT_ARG, 0, 0, 0, 0, 0, 0}, -- cgit v1.2.1