diff options
Diffstat (limited to 'sql/mysqld.cc')
-rw-r--r-- | sql/mysqld.cc | 196 |
1 files changed, 34 insertions, 162 deletions
diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 0794d7fee61..f842c835f24 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -738,27 +738,6 @@ mysql_cond_t COND_server_started; int mysqld_server_started=0, mysqld_server_initialized= 0; File_parser_dummy_hook file_parser_dummy_hook; -#ifdef WITH_WSREP -mysql_mutex_t LOCK_wsrep_ready; -mysql_cond_t COND_wsrep_ready; -mysql_mutex_t LOCK_wsrep_sst; -mysql_cond_t COND_wsrep_sst; -mysql_mutex_t LOCK_wsrep_sst_init; -mysql_cond_t COND_wsrep_sst_init; -mysql_mutex_t LOCK_wsrep_rollback; -mysql_cond_t COND_wsrep_rollback; -wsrep_aborting_thd_t wsrep_aborting_thd= NULL; -mysql_mutex_t LOCK_wsrep_replaying; -mysql_cond_t COND_wsrep_replaying; -mysql_mutex_t LOCK_wsrep_slave_threads; -mysql_mutex_t LOCK_wsrep_desync; -int wsrep_replaying= 0; -ulong wsrep_running_threads = 0; // # of currently running wsrep threads -ulong my_bind_addr; -const char *wsrep_binlog_format_names[]= - {"MIXED", "STATEMENT", "ROW", "NONE", NullS}; -#endif /* WITH_WSREP */ - /* replication parameters, if master_host is not NULL, we are a slave */ uint report_port= 0; ulong master_retry_count=0; @@ -896,12 +875,6 @@ PSI_mutex_key key_BINLOG_LOCK_index, key_BINLOG_LOCK_xid_list, key_LOCK_error_messages, key_LOG_INFO_lock, key_LOCK_thread_count, key_LOCK_thread_cache, key_PARTITION_LOCK_auto_inc; -#ifdef WITH_WSREP -PSI_mutex_key key_LOCK_wsrep_rollback, key_LOCK_wsrep_thd, - key_LOCK_wsrep_replaying, key_LOCK_wsrep_ready, key_LOCK_wsrep_sst, - key_LOCK_wsrep_sst_thread, key_LOCK_wsrep_sst_init, - key_LOCK_wsrep_slave_threads, key_LOCK_wsrep_desync; -#endif PSI_mutex_key key_RELAYLOG_LOCK_index; PSI_mutex_key key_LOCK_slave_state, key_LOCK_binlog_state, key_LOCK_rpl_thread, key_LOCK_rpl_thread_pool, key_LOCK_parallel_entry; @@ -976,18 +949,6 @@ static PSI_mutex_info all_server_mutexes[]= { &key_LOCK_prepare_ordered, "LOCK_prepare_ordered", PSI_FLAG_GLOBAL}, { &key_LOCK_commit_ordered, "LOCK_commit_ordered", PSI_FLAG_GLOBAL}, { &key_LOG_INFO_lock, "LOG_INFO::lock", 0}, -#ifdef WITH_WSREP - { &key_LOCK_wsrep_ready, "LOCK_wsrep_ready", PSI_FLAG_GLOBAL}, - { &key_LOCK_wsrep_sst, "LOCK_wsrep_sst", PSI_FLAG_GLOBAL}, - { &key_LOCK_wsrep_sst_thread, "wsrep_sst_thread", 0}, - { &key_LOCK_wsrep_sst_init, "LOCK_wsrep_sst_init", PSI_FLAG_GLOBAL}, - { &key_LOCK_wsrep_sst, "LOCK_wsrep_sst", PSI_FLAG_GLOBAL}, - { &key_LOCK_wsrep_rollback, "LOCK_wsrep_rollback", PSI_FLAG_GLOBAL}, - { &key_LOCK_wsrep_thd, "THD::LOCK_wsrep_thd", 0}, - { &key_LOCK_wsrep_replaying, "LOCK_wsrep_replaying", PSI_FLAG_GLOBAL}, - { &key_LOCK_wsrep_slave_threads, "LOCK_wsrep_slave_threads", PSI_FLAG_GLOBAL}, - { &key_LOCK_wsrep_desync, "LOCK_wsrep_desync", PSI_FLAG_GLOBAL}, -#endif { &key_LOCK_thread_count, "LOCK_thread_count", PSI_FLAG_GLOBAL}, { &key_LOCK_thread_cache, "LOCK_thread_cache", PSI_FLAG_GLOBAL}, { &key_PARTITION_LOCK_auto_inc, "HA_DATA_PARTITION::LOCK_auto_inc", 0}, @@ -1034,11 +995,6 @@ PSI_cond_key key_BINLOG_COND_xid_list, key_BINLOG_update_cond, key_TABLE_SHARE_cond, key_user_level_lock_cond, key_COND_thread_count, key_COND_thread_cache, key_COND_flush_thread_cache, key_BINLOG_COND_queue_busy; -#ifdef WITH_WSREP -PSI_cond_key key_COND_wsrep_rollback, key_COND_wsrep_thd, - key_COND_wsrep_replaying, key_COND_wsrep_ready, key_COND_wsrep_sst, - key_COND_wsrep_sst_init, key_COND_wsrep_sst_thread; -#endif /* WITH_WSREP */ PSI_cond_key key_RELAYLOG_update_cond, key_COND_wakeup_ready, key_COND_wait_commit; PSI_cond_key key_RELAYLOG_COND_queue_busy; @@ -1088,15 +1044,6 @@ static PSI_cond_info all_server_conds[]= { &key_user_level_lock_cond, "User_level_lock::cond", 0}, { &key_COND_thread_count, "COND_thread_count", PSI_FLAG_GLOBAL}, { &key_COND_thread_cache, "COND_thread_cache", PSI_FLAG_GLOBAL}, -#ifdef WITH_WSREP - { &key_COND_wsrep_ready, "COND_wsrep_ready", PSI_FLAG_GLOBAL}, - { &key_COND_wsrep_sst, "COND_wsrep_sst", PSI_FLAG_GLOBAL}, - { &key_COND_wsrep_sst_init, "COND_wsrep_sst_init", PSI_FLAG_GLOBAL}, - { &key_COND_wsrep_sst_thread, "wsrep_sst_thread", 0}, - { &key_COND_wsrep_rollback, "COND_wsrep_rollback", PSI_FLAG_GLOBAL}, - { &key_COND_wsrep_thd, "THD::COND_wsrep_thd", 0}, - { &key_COND_wsrep_replaying, "COND_wsrep_replaying", PSI_FLAG_GLOBAL}, -#endif { &key_COND_flush_thread_cache, "COND_flush_thread_cache", PSI_FLAG_GLOBAL}, { &key_COND_rpl_thread, "COND_rpl_thread", 0}, { &key_COND_rpl_thread_queue, "COND_rpl_thread_queue", 0}, @@ -1945,17 +1892,13 @@ static void __cdecl kill_server(int sig_ptr) } #endif -#ifdef WITH_WSREP if (WSREP_ON) wsrep_stop_replication(NULL); -#endif close_connections(); -#ifdef WITH_WSREP if (wsrep_inited == 1) wsrep_deinit(true); -#endif if (sig != MYSQL_KILL_SIGNAL && sig != 0) @@ -2062,10 +2005,9 @@ extern "C" void unireg_abort(int exit_code) */ wsrep_close_client_connections(FALSE); shutdown_in_progress= 1; - THD *thd(0); wsrep->disconnect(wsrep); WSREP_INFO("Service disconnected."); - wsrep_close_threads(thd); /* this won't close all threads */ + wsrep_close_threads(NULL); /* this won't close all threads */ sleep(1); /* so give some time to exit for those which can */ WSREP_INFO("Some threads may fail to exit."); @@ -2294,20 +2236,6 @@ static void clean_up_mutexes() mysql_cond_destroy(&COND_thread_count); mysql_cond_destroy(&COND_thread_cache); mysql_cond_destroy(&COND_flush_thread_cache); -#ifdef WITH_WSREP - (void) mysql_mutex_destroy(&LOCK_wsrep_ready); - (void) mysql_cond_destroy(&COND_wsrep_ready); - (void) mysql_mutex_destroy(&LOCK_wsrep_sst); - (void) mysql_cond_destroy(&COND_wsrep_sst); - (void) mysql_mutex_destroy(&LOCK_wsrep_sst_init); - (void) mysql_cond_destroy(&COND_wsrep_sst_init); - (void) mysql_mutex_destroy(&LOCK_wsrep_rollback); - (void) mysql_cond_destroy(&COND_wsrep_rollback); - (void) mysql_mutex_destroy(&LOCK_wsrep_replaying); - (void) mysql_cond_destroy(&COND_wsrep_replaying); - (void) mysql_mutex_destroy(&LOCK_wsrep_slave_threads); - (void) mysql_mutex_destroy(&LOCK_wsrep_desync); -#endif mysql_mutex_destroy(&LOCK_server_started); mysql_cond_destroy(&COND_server_started); mysql_mutex_destroy(&LOCK_prepare_ordered); @@ -2321,7 +2249,12 @@ static void clean_up_mutexes() ** Init IP and UNIX socket ****************************************************************************/ -#ifndef EMBEDDED_LIBRARY +#ifdef EMBEDDED_LIBRARY +static void set_ports() +{ +} + +#else static void set_ports() { char *env; @@ -2623,10 +2556,10 @@ static MYSQL_SOCKET activate_tcp_port(uint port) socket_errno); unireg_abort(1); } -#if defined(WITH_WSREP) && defined(HAVE_FCNTL) && defined(FD_CLOEXEC) - if (WSREP_ON) - (void) fcntl(mysql_socket_getfd(ip_sock), F_SETFD, FD_CLOEXEC); -#endif /* WITH_WSREP */ + +#ifdef FD_CLOEXEC + (void) fcntl(mysql_socket_getfd(ip_sock), F_SETFD, FD_CLOEXEC); +#endif DBUG_RETURN(ip_sock); } @@ -2754,10 +2687,9 @@ static void network_init(void) if (mysql_socket_listen(unix_sock,(int) back_log) < 0) sql_print_warning("listen() on Unix socket failed with error %d", socket_errno); -#if defined(WITH_WSREP) && defined(HAVE_FCNTL) && defined(FD_CLOEXEC) - if (WSREP_ON) - (void) fcntl(mysql_socket_getfd(unix_sock), F_SETFD, FD_CLOEXEC); -#endif /* WITH_WSREP */ +#ifdef FD_CLOEXEC + (void) fcntl(mysql_socket_getfd(unix_sock), F_SETFD, FD_CLOEXEC); +#endif } #endif DBUG_PRINT("info",("server started")); @@ -3012,15 +2944,13 @@ static bool cache_thread() bool one_thread_per_connection_end(THD *thd, bool put_in_cache) { DBUG_ENTER("one_thread_per_connection_end"); -#ifdef WITH_WSREP - const bool wsrep_applier(thd->wsrep_applier); -#endif + const bool wsrep_applier= IF_WSREP(thd->wsrep_applier, false); unlink_thd(thd); /* Mark that current_thd is not valid anymore */ set_current_thd(0); - if (put_in_cache && cache_thread() && IF_WSREP(!wsrep_applier, 1)) + if (put_in_cache && cache_thread() && !wsrep_applier) DBUG_RETURN(0); // Thread is reused /* @@ -4145,7 +4075,7 @@ static int init_common_variables() opt_log_basename= glob_hostname; #ifdef WITH_WSREP - if (0 == wsrep_node_name || 0 == wsrep_node_name[0]) + if (wsrep_node_name == 0 || wsrep_node_name[0] == 0) { my_free((void *)wsrep_node_name); wsrep_node_name= my_strdup(glob_hostname, MYF(MY_WME)); @@ -4616,28 +4546,6 @@ static int init_thread_environment() rpl_init_gtid_waiting(); #endif -#ifdef WITH_WSREP - mysql_mutex_init(key_LOCK_wsrep_ready, - &LOCK_wsrep_ready, MY_MUTEX_INIT_FAST); - mysql_cond_init(key_COND_wsrep_ready, &COND_wsrep_ready, NULL); - mysql_mutex_init(key_LOCK_wsrep_sst, - &LOCK_wsrep_sst, MY_MUTEX_INIT_FAST); - mysql_cond_init(key_COND_wsrep_sst, &COND_wsrep_sst, NULL); - mysql_mutex_init(key_LOCK_wsrep_sst_init, - &LOCK_wsrep_sst_init, MY_MUTEX_INIT_FAST); - mysql_cond_init(key_COND_wsrep_sst_init, &COND_wsrep_sst_init, NULL); - mysql_mutex_init(key_LOCK_wsrep_rollback, - &LOCK_wsrep_rollback, MY_MUTEX_INIT_FAST); - mysql_cond_init(key_COND_wsrep_rollback, &COND_wsrep_rollback, NULL); - mysql_mutex_init(key_LOCK_wsrep_replaying, - &LOCK_wsrep_replaying, MY_MUTEX_INIT_FAST); - mysql_cond_init(key_COND_wsrep_replaying, &COND_wsrep_replaying, NULL); - mysql_mutex_init(key_LOCK_wsrep_slave_threads, - &LOCK_wsrep_slave_threads, MY_MUTEX_INIT_FAST); - mysql_mutex_init(key_LOCK_wsrep_desync, - &LOCK_wsrep_desync, MY_MUTEX_INIT_FAST); -#endif - DBUG_RETURN(0); } @@ -4935,10 +4843,10 @@ static int init_server_components() /* need to configure logging before initializing storage engines */ if (!opt_bin_log_used) { - if (IF_WSREP(!WSREP_ON,1) && opt_log_slave_updates) + if (!WSREP_ON && opt_log_slave_updates) sql_print_warning("You need to use --log-bin to make " "--log-slave-updates work."); - if (IF_WSREP(!WSREP_ON, 1) && binlog_format_used) + if (!WSREP_ON && binlog_format_used) sql_print_warning("You need to use --log-bin to make " "--binlog-format work."); } @@ -5010,10 +4918,9 @@ a file name for --log-bin-index option", opt_binlog_index_name); opt_log_basename, ln); } if (ln == buf) - { opt_bin_logname= my_once_strdup(buf, MYF(MY_WME)); - } -#ifdef WITH_WSREP /* WSREP BEFORE SE */ + } + /* Wsrep initialization must happen at this point, because: - opt_bin_logname must be known when starting replication @@ -5021,19 +4928,19 @@ a file name for --log-bin-index option", opt_binlog_index_name); - SST may modify binlog index file, so it must be opened after SST has happened */ - } - if (WSREP_ON && !wsrep_recovery) + if (WSREP_ON && !wsrep_recovery) /* WSREP BEFORE SE */ { if (opt_bootstrap) // bootsrap option given - disable wsrep functionality { wsrep_provider_init(WSREP_NONE); - if (wsrep_init()) unireg_abort(1); + if (wsrep_init()) + unireg_abort(1); } else // full wsrep initialization { // add basedir/bin to PATH to resolve wsrep script names - char* const tmp_path((char*)alloca(strlen(mysql_home) + - strlen("/bin") + 1)); + char* const tmp_path= (char*)my_alloca(strlen(mysql_home) + + strlen("/bin") + 1); if (tmp_path) { strcpy(tmp_path, mysql_home); @@ -5044,6 +4951,7 @@ a file name for --log-bin-index option", opt_binlog_index_name); { WSREP_ERROR("Could not append %s/bin to PATH", mysql_home); } + my_afree(tmp_path); if (wsrep_before_SE()) { @@ -5053,27 +4961,14 @@ a file name for --log-bin-index option", opt_binlog_index_name); } } } + if (opt_bin_log) { - /* - Variable ln is not defined at this scope. We use opt_bin_logname instead. - It should be the same as ln since - - mysql_bin_log.generate_name() returns first argument if new log name - is not generated - - if new log name is generated, return value is assigned to ln and copied - to opt_bin_logname above - */ if (mysql_bin_log.open_index_file(opt_binlog_index_name, opt_bin_logname, TRUE)) { unireg_abort(1); } -#else - if (mysql_bin_log.open_index_file(opt_binlog_index_name, ln, TRUE)) - { - unireg_abort(1); - } -#endif /* WITH_WSREP */ } /* call ha_init_key_cache() on all key caches to init them */ @@ -5206,7 +5101,6 @@ a file name for --log-bin-index option", opt_binlog_index_name); tc_log= get_tc_log_implementation(); -#ifdef WITH_WSREP if (WSREP_ON && tc_log == &tc_log_mmap) tc_log= &tc_log_dummy; @@ -5215,7 +5109,6 @@ a file name for --log-bin-index option", opt_binlog_index_name); (tc_log == &tc_log_mmap) ? "mmap" : (tc_log == &tc_log_dummy) ? "dummy" : "unknown" ); -#endif if (tc_log->open(opt_bin_log ? opt_bin_logname : opt_tc_log_file)) { @@ -5474,10 +5367,9 @@ int mysqld_main(int argc, char **argv) return 1; } #endif -#ifdef WITH_WSREP + if (WSREP_ON) wsrep_filter_new_cluster (&argc, argv); -#endif /* WITH_WSREP */ orig_argc= argc; orig_argv= argv; @@ -5694,14 +5586,12 @@ int mysqld_main(int argc, char **argv) } #endif -#ifdef WITH_WSREP /* WSREP AFTER SE */ if (WSREP_ON && wsrep_recovery) { select_thread_in_use= 0; wsrep_recover(); unireg_abort(0); } -#endif /* WITH_WSREP */ /* init signals & alarm @@ -5751,7 +5641,6 @@ int mysqld_main(int argc, char **argv) if (Events::init(opt_noacl || opt_bootstrap)) unireg_abort(1); -#ifdef WITH_WSREP /* WSREP AFTER SE */ if (WSREP_ON) { if (opt_bootstrap) @@ -5778,7 +5667,7 @@ int mysqld_main(int argc, char **argv) wsrep_create_appliers(wsrep_slave_threads - 1); } } -#endif /* WITH_WSREP */ + if (opt_bootstrap) { select_thread_in_use= 0; // Allow 'kill' to work @@ -6517,9 +6406,9 @@ void handle_connections_sockets() sleep(1); // Give other threads some time continue; } -#if defined(WITH_WSREP) && defined(HAVE_FCNTL) && defined(FD_CLOEXEC) +#ifdef FD_CLOEXEC (void) fcntl(mysql_socket_getfd(new_sock), F_SETFD, FD_CLOEXEC); -#endif /* WITH_WSREP */ +#endif #ifdef HAVE_LIBWRAP { @@ -8293,21 +8182,6 @@ SHOW_VAR status_vars[]= { #ifdef ENABLED_PROFILING {"Uptime_since_flush_status",(char*) &show_flushstatustime, SHOW_SIMPLE_FUNC}, #endif -#ifdef WITH_WSREP - {"wsrep_connected", (char*) &wsrep_connected, SHOW_BOOL}, - {"wsrep_ready", (char*) &wsrep_ready, SHOW_BOOL}, - {"wsrep_cluster_state_uuid", (char*) &wsrep_cluster_state_uuid,SHOW_CHAR_PTR}, - {"wsrep_cluster_conf_id", (char*) &wsrep_cluster_conf_id, SHOW_LONGLONG}, - {"wsrep_cluster_status", (char*) &wsrep_cluster_status, SHOW_CHAR_PTR}, - {"wsrep_cluster_size", (char*) &wsrep_cluster_size, SHOW_LONG_NOFLUSH}, - {"wsrep_local_index", (char*) &wsrep_local_index, SHOW_LONG_NOFLUSH}, - {"wsrep_local_bf_aborts", (char*) &wsrep_show_bf_aborts, SHOW_SIMPLE_FUNC}, - {"wsrep_provider_name", (char*) &wsrep_provider_name, SHOW_CHAR_PTR}, - {"wsrep_provider_version", (char*) &wsrep_provider_version, SHOW_CHAR_PTR}, - {"wsrep_provider_vendor", (char*) &wsrep_provider_vendor, SHOW_CHAR_PTR}, - {"wsrep_thread_count", (char*) &wsrep_running_threads, SHOW_LONG_NOFLUSH}, - {"wsrep", (char*) &wsrep_show_status, SHOW_FUNC}, -#endif {NullS, NullS, SHOW_LONG} }; @@ -8651,10 +8525,10 @@ static int mysql_init_variables(void) tmpenv = DEFAULT_MYSQL_HOME; strmake_buf(mysql_home, tmpenv); #endif -#ifdef WITH_WSREP + if (WSREP_ON && wsrep_init_vars()) return 1; -#endif + return 0; } @@ -8902,14 +8776,12 @@ mysqld_get_one_option(int optid, case OPT_LOWER_CASE_TABLE_NAMES: lower_case_table_names_used= 1; break; -#ifdef WITH_WSREP case OPT_WSREP_START_POSITION: wsrep_start_position_init (argument); break; case OPT_WSREP_SST_AUTH: wsrep_sst_auth_init (argument); break; -#endif #if defined(ENABLED_DEBUG_SYNC) case OPT_DEBUG_SYNC_TIMEOUT: /* |