diff options
Diffstat (limited to 'sql/mysqld.cc')
-rw-r--r-- | sql/mysqld.cc | 716 |
1 files changed, 446 insertions, 270 deletions
diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 2ad4e6f2a61..1a3ff53be6f 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -14,7 +14,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "sql_plugin.h" // Includes my_global.h +#include "sql_plugin.h" // Includes mariadb.h #include "sql_priv.h" #include "unireg.h" #include <signal.h> @@ -46,7 +46,6 @@ #include "sql_servers.h" // servers_free, servers_init #include "init.h" // unireg_init #include "derror.h" // init_errmessage -#include "derror.h" // init_errmessage #include "des_key_file.h" // load_des_key_file #include "sql_manager.h" // stop_handle_manager, start_handle_manager #include "sql_expression_cache.h" // subquery_cache_miss, subquery_cache_hit @@ -75,6 +74,7 @@ #include "wsrep_var.h" #include "wsrep_thd.h" #include "wsrep_sst.h" +#include "proxy_protocol.h" #include "sql_callback.h" #include "threadpool.h" @@ -96,8 +96,10 @@ #include "set_var.h" #include "rpl_injector.h" +#include "semisync_master.h" +#include "semisync_slave.h" -#include "rpl_handler.h" +#include "transaction.h" #ifdef HAVE_SYS_PRCTL_H #include <sys/prctl.h> @@ -300,7 +302,7 @@ static TYPELIB tc_heuristic_recover_typelib= tc_heuristic_recover_names, NULL }; -const char *first_keyword= "first", *binary_keyword= "BINARY"; +const char *first_keyword= "first"; const char *my_localhost= "localhost", *delayed_user= "DELAYED"; bool opt_large_files= sizeof(my_off_t) > 4; @@ -311,14 +313,6 @@ static my_bool opt_autocommit; ///< for --autocommit command-line option */ static my_bool opt_verbose= 0; -arg_cmp_func Arg_comparator::comparator_matrix[6][2] = -{{&Arg_comparator::compare_string, &Arg_comparator::compare_e_string}, - {&Arg_comparator::compare_real, &Arg_comparator::compare_e_real}, - {&Arg_comparator::compare_int_signed, &Arg_comparator::compare_e_int}, - {&Arg_comparator::compare_row, &Arg_comparator::compare_e_row}, - {&Arg_comparator::compare_decimal, &Arg_comparator::compare_e_decimal}, - {&Arg_comparator::compare_datetime, &Arg_comparator::compare_e_datetime}}; - /* Timer info to be used by the SQL layer */ MY_TIMER_INFO sys_timer_info; @@ -380,6 +374,8 @@ char *my_bind_addr_str; static char *default_collation_name; char *default_storage_engine, *default_tmp_storage_engine; char *enforced_storage_engine=NULL; +char *gtid_pos_auto_engines; +plugin_ref *opt_gtid_pos_auto_plugins; static char compiled_default_collation_name[]= MYSQL_DEFAULT_COLLATION_NAME; static I_List<CONNECT> thread_cache; static bool binlog_format_used= false; @@ -388,6 +384,7 @@ mysql_cond_t COND_thread_cache; static mysql_cond_t COND_flush_thread_cache; mysql_cond_t COND_slave_background; static DYNAMIC_ARRAY all_options; +static longlong start_memory_used; /* Global variables */ @@ -400,7 +397,6 @@ my_bool disable_log_notes, opt_support_flashback= 0; static my_bool opt_abort; ulonglong log_output_options; my_bool opt_userstat_running; -my_bool opt_log_queries_not_using_indexes= 0; bool opt_error_log= IF_WIN(1,0); bool opt_disable_networking=0, opt_skip_show_db=0; bool opt_skip_name_resolve=0; @@ -448,6 +444,7 @@ my_bool opt_replicate_annotate_row_events= 0; my_bool opt_mysql56_temporal_format=0, strict_password_validation= 1; my_bool opt_explicit_defaults_for_timestamp= 0; char *opt_slave_skip_errors; +char *opt_slave_transaction_retry_errors; /* Legacy global handlerton. These will be removed (please do not add more). @@ -462,8 +459,6 @@ my_bool relay_log_recovery; my_bool opt_sync_frm, opt_allow_suspicious_udfs; my_bool opt_secure_auth= 0; char* opt_secure_file_priv; -my_bool opt_log_slow_admin_statements= 0; -my_bool opt_log_slow_slave_statements= 0; my_bool lower_case_file_system= 0; my_bool opt_large_pages= 0; my_bool opt_super_large_pages= 0; @@ -497,7 +492,6 @@ uint protocol_version; uint lower_case_table_names; ulong tc_heuristic_recover= 0; int32 thread_count, service_thread_count; -int32 thread_running; int32 slave_open_temp_tables; ulong thread_created; ulong back_log, connect_timeout, concurrency, server_id; @@ -505,6 +499,7 @@ ulong what_to_log; ulong slow_launch_time; ulong open_files_limit, max_binlog_size; ulong slave_trans_retries; +ulong slave_trans_retry_interval; uint slave_net_timeout; ulong slave_exec_mode_options; ulong slave_run_triggers_for_rbr= 0; @@ -512,6 +507,7 @@ ulong slave_ddl_exec_mode_options= SLAVE_EXEC_MODE_IDEMPOTENT; ulonglong slave_type_conversions_options; ulong thread_cache_size=0; ulonglong binlog_cache_size=0; +ulonglong binlog_file_cache_size=0; ulonglong max_binlog_cache_size=0; ulong slave_max_allowed_packet= 0; ulonglong binlog_stmt_cache_size=0; @@ -532,10 +528,14 @@ ulong max_connections, max_connect_errors; ulong extra_max_connections; uint max_digest_length= 0; ulong slave_retried_transactions; +ulong transactions_multi_engine; +ulong rpl_transactions_multi_engine; +ulong transactions_gtid_foreign_engine; ulonglong slave_skipped_errors; ulong feature_files_opened_with_delayed_keys= 0, feature_check_constraint= 0; ulonglong denied_connections; my_decimal decimal_zero; +long opt_secure_timestamp; /* Maximum length of parameter value which can be set through @@ -626,7 +626,7 @@ char mysql_real_data_home[FN_REFLEN], *opt_init_file, *opt_tc_log_file; char *lc_messages_dir_ptr= lc_messages_dir, *log_error_file_ptr; char mysql_unpacked_real_data_home[FN_REFLEN]; -int mysql_unpacked_real_data_home_len; +size_t mysql_unpacked_real_data_home_len; uint mysql_real_data_home_len, mysql_data_home_len= 1; uint reg_ext_length; const key_map key_map_empty(0); @@ -645,10 +645,10 @@ my_bool encrypt_binlog; my_bool encrypt_tmp_disk_tables, encrypt_tmp_files; /** name of reference on left expression in rewritten IN subquery */ -const char *in_left_expr_name= "<left expr>"; +const LEX_CSTRING in_left_expr_name= {STRING_WITH_LEN("<left expr>") }; /** name of additional condition */ -const char *in_additional_cond= "<IN COND>"; -const char *in_having_cond= "<IN HAVING>"; +const LEX_CSTRING in_having_cond= {STRING_WITH_LEN("<IN HAVING>") }; +const LEX_CSTRING in_additional_cond= {STRING_WITH_LEN("<IN COND>") }; /** Number of connection errors when selecting on the listening port */ ulong connection_errors_select= 0; @@ -915,7 +915,7 @@ PSI_mutex_key key_LOCK_des_key_file; PSI_mutex_key key_BINLOG_LOCK_index, key_BINLOG_LOCK_xid_list, key_BINLOG_LOCK_binlog_background_thread, - m_key_LOCK_binlog_end_pos, + key_LOCK_binlog_end_pos, key_delayed_insert_mutex, key_hash_filo_lock, key_LOCK_active_mi, key_LOCK_connection_count, key_LOCK_crypt, key_LOCK_delayed_create, key_LOCK_delayed_insert, key_LOCK_delayed_status, key_LOCK_error_log, @@ -937,9 +937,11 @@ PSI_mutex_key key_BINLOG_LOCK_index, key_BINLOG_LOCK_xid_list, key_LOCK_thread_count, key_LOCK_thread_cache, key_PARTITION_LOCK_auto_inc; PSI_mutex_key key_RELAYLOG_LOCK_index; +PSI_mutex_key key_LOCK_relaylog_end_pos; PSI_mutex_key key_LOCK_thread_id; PSI_mutex_key key_LOCK_slave_state, key_LOCK_binlog_state, key_LOCK_rpl_thread, key_LOCK_rpl_thread_pool, key_LOCK_parallel_entry; +PSI_mutex_key key_LOCK_binlog; PSI_mutex_key key_LOCK_stats, key_LOCK_global_user_client_stats, key_LOCK_global_table_stats, @@ -951,6 +953,10 @@ PSI_mutex_key key_LOCK_after_binlog_sync; PSI_mutex_key key_LOCK_prepare_ordered, key_LOCK_commit_ordered, key_LOCK_slave_background; PSI_mutex_key key_TABLE_SHARE_LOCK_share; +PSI_mutex_key key_LOCK_ack_receiver; + +PSI_mutex_key key_TABLE_SHARE_LOCK_rotation; +PSI_cond_key key_TABLE_SHARE_COND_rotation; static PSI_mutex_info all_server_mutexes[]= { @@ -969,8 +975,9 @@ static PSI_mutex_info all_server_mutexes[]= { &key_BINLOG_LOCK_index, "MYSQL_BIN_LOG::LOCK_index", 0}, { &key_BINLOG_LOCK_xid_list, "MYSQL_BIN_LOG::LOCK_xid_list", 0}, { &key_BINLOG_LOCK_binlog_background_thread, "MYSQL_BIN_LOG::LOCK_binlog_background_thread", 0}, - { &m_key_LOCK_binlog_end_pos, "MYSQL_BIN_LOG::LOCK_binlog_end_pos", 0 }, + { &key_LOCK_binlog_end_pos, "MYSQL_BIN_LOG::LOCK_binlog_end_pos", 0 }, { &key_RELAYLOG_LOCK_index, "MYSQL_RELAY_LOG::LOCK_index", 0}, + { &key_LOCK_relaylog_end_pos, "MYSQL_RELAY_LOG::LOCK_binlog_end_pos", 0}, { &key_delayed_insert_mutex, "Delayed_insert::mutex", 0}, { &key_hash_filo_lock, "hash_filo::lock", 0}, { &key_LOCK_active_mi, "LOCK_active_mi", PSI_FLAG_GLOBAL}, @@ -1014,6 +1021,7 @@ static PSI_mutex_info all_server_mutexes[]= { &key_structure_guard_mutex, "Query_cache::structure_guard_mutex", 0}, { &key_TABLE_SHARE_LOCK_ha_data, "TABLE_SHARE::LOCK_ha_data", 0}, { &key_TABLE_SHARE_LOCK_share, "TABLE_SHARE::LOCK_share", 0}, + { &key_TABLE_SHARE_LOCK_rotation, "TABLE_SHARE::LOCK_rotation", 0}, { &key_LOCK_error_messages, "LOCK_error_messages", PSI_FLAG_GLOBAL}, { &key_LOCK_prepare_ordered, "LOCK_prepare_ordered", PSI_FLAG_GLOBAL}, { &key_LOCK_after_binlog_sync, "LOCK_after_binlog_sync", PSI_FLAG_GLOBAL}, @@ -1028,12 +1036,16 @@ static PSI_mutex_info all_server_mutexes[]= { &key_LOCK_binlog_state, "LOCK_binlog_state", 0}, { &key_LOCK_rpl_thread, "LOCK_rpl_thread", 0}, { &key_LOCK_rpl_thread_pool, "LOCK_rpl_thread_pool", 0}, - { &key_LOCK_parallel_entry, "LOCK_parallel_entry", 0} + { &key_LOCK_parallel_entry, "LOCK_parallel_entry", 0}, + { &key_LOCK_ack_receiver, "Ack_receiver::mutex", 0}, + { &key_LOCK_binlog, "LOCK_binlog", 0} }; PSI_rwlock_key key_rwlock_LOCK_grant, key_rwlock_LOCK_logger, key_rwlock_LOCK_sys_init_connect, key_rwlock_LOCK_sys_init_slave, - key_rwlock_LOCK_system_variables_hash, key_rwlock_query_cache_query_lock; + key_rwlock_LOCK_system_variables_hash, key_rwlock_query_cache_query_lock, + key_LOCK_SEQUENCE, + key_rwlock_LOCK_vers_stats, key_rwlock_LOCK_stat_serial; static PSI_rwlock_info all_server_rwlocks[]= { @@ -1044,15 +1056,19 @@ static PSI_rwlock_info all_server_rwlocks[]= { &key_rwlock_LOCK_logger, "LOGGER::LOCK_logger", 0}, { &key_rwlock_LOCK_sys_init_connect, "LOCK_sys_init_connect", PSI_FLAG_GLOBAL}, { &key_rwlock_LOCK_sys_init_slave, "LOCK_sys_init_slave", PSI_FLAG_GLOBAL}, + { &key_LOCK_SEQUENCE, "LOCK_SEQUENCE", 0}, { &key_rwlock_LOCK_system_variables_hash, "LOCK_system_variables_hash", PSI_FLAG_GLOBAL}, - { &key_rwlock_query_cache_query_lock, "Query_cache_query::lock", 0} + { &key_rwlock_query_cache_query_lock, "Query_cache_query::lock", 0}, + { &key_rwlock_LOCK_vers_stats, "Vers_field_stats::lock", 0}, + { &key_rwlock_LOCK_stat_serial, "TABLE_SHARE::LOCK_stat_serial", 0} }; #ifdef HAVE_MMAP PSI_cond_key key_PAGE_cond, key_COND_active, key_COND_pool; #endif /* HAVE_MMAP */ -PSI_cond_key key_BINLOG_COND_xid_list, key_BINLOG_update_cond, +PSI_cond_key key_BINLOG_COND_xid_list, + key_BINLOG_COND_bin_log_updated, key_BINLOG_COND_relay_log_updated, key_BINLOG_COND_binlog_background_thread, key_BINLOG_COND_binlog_background_thread_end, key_COND_cache_status_changed, key_COND_manager, @@ -1066,9 +1082,10 @@ PSI_cond_key key_BINLOG_COND_xid_list, key_BINLOG_update_cond, key_rpl_group_info_sleep_cond, key_TABLE_SHARE_cond, key_user_level_lock_cond, key_COND_thread_count, key_COND_thread_cache, key_COND_flush_thread_cache, - key_COND_start_thread, + key_COND_start_thread, key_COND_binlog_send, key_BINLOG_COND_queue_busy; -PSI_cond_key key_RELAYLOG_update_cond, key_COND_wakeup_ready, +PSI_cond_key key_RELAYLOG_COND_relay_log_updated, + key_RELAYLOG_COND_bin_log_updated, key_COND_wakeup_ready, key_COND_wait_commit; PSI_cond_key key_RELAYLOG_COND_queue_busy; PSI_cond_key key_TC_LOG_MMAP_COND_queue_busy; @@ -1077,6 +1094,7 @@ PSI_cond_key key_COND_rpl_thread_queue, key_COND_rpl_thread, key_COND_parallel_entry, key_COND_group_commit_orderer, key_COND_prepare_ordered, key_COND_slave_background; PSI_cond_key key_COND_wait_gtid, key_COND_gtid_ignore_duplicates; +PSI_cond_key key_COND_ack_receiver; static PSI_cond_info all_server_conds[]= { @@ -1089,12 +1107,13 @@ static PSI_cond_info all_server_conds[]= { &key_COND_pool, "TC_LOG_MMAP::COND_pool", 0}, { &key_TC_LOG_MMAP_COND_queue_busy, "TC_LOG_MMAP::COND_queue_busy", 0}, #endif /* HAVE_MMAP */ + { &key_BINLOG_COND_bin_log_updated, "MYSQL_BIN_LOG::COND_bin_log_updated", 0}, { &key_BINLOG_COND_relay_log_updated, "MYSQL_BIN_LOG::COND_relay_log_updated", 0}, { &key_BINLOG_COND_xid_list, "MYSQL_BIN_LOG::COND_xid_list", 0}, - { &key_BINLOG_update_cond, "MYSQL_BIN_LOG::update_cond", 0}, { &key_BINLOG_COND_binlog_background_thread, "MYSQL_BIN_LOG::COND_binlog_background_thread", 0}, { &key_BINLOG_COND_binlog_background_thread_end, "MYSQL_BIN_LOG::COND_binlog_background_thread_end", 0}, { &key_BINLOG_COND_queue_busy, "MYSQL_BIN_LOG::COND_queue_busy", 0}, - { &key_RELAYLOG_update_cond, "MYSQL_RELAY_LOG::update_cond", 0}, + { &key_RELAYLOG_COND_relay_log_updated, "MYSQL_RELAY_LOG::COND_relay_log_updated", 0}, + { &key_RELAYLOG_COND_bin_log_updated, "MYSQL_RELAY_LOG::COND_bin_log_updated", 0}, { &key_RELAYLOG_COND_queue_busy, "MYSQL_RELAY_LOG::COND_queue_busy", 0}, { &key_COND_wakeup_ready, "THD::COND_wakeup_ready", 0}, { &key_COND_wait_commit, "wait_for_commit::COND_wait_commit", 0}, @@ -1128,13 +1147,17 @@ static PSI_cond_info all_server_conds[]= { &key_COND_slave_background, "COND_slave_background", 0}, { &key_COND_start_thread, "COND_start_thread", PSI_FLAG_GLOBAL}, { &key_COND_wait_gtid, "COND_wait_gtid", 0}, - { &key_COND_gtid_ignore_duplicates, "COND_gtid_ignore_duplicates", 0} + { &key_COND_gtid_ignore_duplicates, "COND_gtid_ignore_duplicates", 0}, + { &key_COND_ack_receiver, "Ack_receiver::cond", 0}, + { &key_COND_binlog_send, "COND_binlog_send", 0}, + { &key_TABLE_SHARE_COND_rotation, "TABLE_SHARE::COND_rotation", 0} }; PSI_thread_key key_thread_bootstrap, key_thread_delayed_insert, key_thread_handle_manager, key_thread_main, key_thread_one_connection, key_thread_signal_hand, key_thread_slave_background, key_rpl_parallel_thread; +PSI_thread_key key_thread_ack_receiver; static PSI_thread_info all_server_threads[]= { @@ -1161,6 +1184,7 @@ static PSI_thread_info all_server_threads[]= { &key_thread_one_connection, "one_connection", 0}, { &key_thread_signal_hand, "signal_handler", PSI_FLAG_GLOBAL}, { &key_thread_slave_background, "slave_background", PSI_FLAG_GLOBAL}, + { &key_thread_ack_receiver, "Ack_receiver", PSI_FLAG_GLOBAL}, { &key_rpl_parallel_thread, "rpl_parallel_thread", 0} }; @@ -1227,7 +1251,7 @@ void net_after_header_psi(struct st_net *net, void *user_data, { thd->m_statement_psi= MYSQL_START_STATEMENT(&thd->m_statement_state, stmt_info_new_packet.m_key, - thd->db, thd->db_length, + thd->get_db(), thd->db.length, thd->charset()); THD_STAGE_INFO(thd, stage_init); @@ -1356,7 +1380,7 @@ private: void Buffered_logs::init() { - init_alloc_root(&m_root, 1024, 0, MYF(0)); + init_alloc_root(&m_root, "Buffered_logs", 1024, 0, MYF(0)); } void Buffered_logs::cleanup() @@ -1638,13 +1662,11 @@ static void close_connections(void) { if (mysql_socket_getfd(base_ip_sock) != INVALID_SOCKET) { - (void) mysql_socket_shutdown(base_ip_sock, SHUT_RDWR); (void) mysql_socket_close(base_ip_sock); base_ip_sock= MYSQL_INVALID_SOCKET; } if (mysql_socket_getfd(extra_ip_sock) != INVALID_SOCKET) { - (void) mysql_socket_shutdown(extra_ip_sock, SHUT_RDWR); (void) mysql_socket_close(extra_ip_sock); extra_ip_sock= MYSQL_INVALID_SOCKET; } @@ -1676,7 +1698,6 @@ static void close_connections(void) #ifdef HAVE_SYS_UN_H if (mysql_socket_getfd(unix_sock) != INVALID_SOCKET) { - (void) mysql_socket_shutdown(unix_sock, SHUT_RDWR); (void) mysql_socket_close(unix_sock); (void) unlink(mysqld_unix_port); unix_sock= MYSQL_INVALID_SOCKET; @@ -1713,7 +1734,7 @@ static void close_connections(void) #endif tmp->set_killed(KILL_SERVER_HARD); MYSQL_CALLBACK(thread_scheduler, post_kill_notification, (tmp)); - mysql_mutex_lock(&tmp->LOCK_thd_data); + mysql_mutex_lock(&tmp->LOCK_thd_kill); if (tmp->mysys_var) { tmp->mysys_var->abort=1; @@ -1736,13 +1757,14 @@ static void close_connections(void) } mysql_mutex_unlock(&tmp->mysys_var->mutex); } - mysql_mutex_unlock(&tmp->LOCK_thd_data); + mysql_mutex_unlock(&tmp->LOCK_thd_kill); } mysql_mutex_unlock(&LOCK_thread_count); // For unlink from list Events::deinit(); slave_prepare_for_shutdown(); mysql_bin_log.stop_background_thread(); + ack_receiver.stop(); /* Give threads time to die. @@ -1936,10 +1958,11 @@ void kill_mysql(THD *thd) pthread_t tmp; int error; abort_loop=1; - if ((error= mysql_thread_create(0, /* Not instrumented */ - &tmp, &connection_attrib, - kill_server_thread, (void*) 0))) - sql_print_error("Can't create thread to kill server (errno= %d).", error); + if (unlikely((error= mysql_thread_create(0, /* Not instrumented */ + &tmp, &connection_attrib, + kill_server_thread, (void*) 0)))) + sql_print_error("Can't create thread to kill server (errno= %d).", + error); } #endif DBUG_VOID_RETURN; @@ -2173,7 +2196,10 @@ static void mysqld_exit(int exit_code) if (!opt_debugging && !my_disable_leak_check && exit_code == 0 && debug_assert_on_not_freed_memory) { - DBUG_ASSERT(global_status_var.global_memory_used == 0); +#ifdef SAFEMALLOC + sf_report_leaked_memory(0); +#endif + DBUG_SLOW_ASSERT(global_status_var.global_memory_used == 0); } cleanup_tls(); DBUG_LEAVE; @@ -2217,12 +2243,14 @@ void clean_up(bool print_message) lex_free(); /* Free some memory */ item_create_cleanup(); tdc_start_shutdown(); +#ifdef HAVE_REPLICATION + semi_sync_master_deinit(); +#endif plugin_shutdown(); udf_free(); ha_end(); if (tc_log) tc_log->close(); - delegates_destroy(); xid_cache_free(); tdc_deinit(); mdl_destroy(); @@ -2253,6 +2281,7 @@ void clean_up(bool print_message) #endif wsrep_thr_deinit(); my_uuid_end(); + delete type_handler_data; delete binlog_filter; delete global_rpl_filter; end_ssl(); @@ -2296,6 +2325,7 @@ void clean_up(bool print_message) my_free(const_cast<char*>(relay_log_index)); #endif free_list(opt_plugin_load_list_ptr); + destroy_proxy_protocol_networks(); /* The following lines may never be executed as the main thread may have @@ -2483,10 +2513,9 @@ static void set_user(const char *user, struct passwd *user_info_arg) allow_coredumps(); } - +#if !defined(__WIN__) static void set_effective_user(struct passwd *user_info_arg) { -#if !defined(__WIN__) DBUG_ASSERT(user_info_arg != 0); if (setregid((gid_t)-1, user_info_arg->pw_gid) == -1) { @@ -2499,9 +2528,8 @@ static void set_effective_user(struct passwd *user_info_arg) unireg_abort(1); } allow_coredumps(); -#endif } - +#endif /** Change root user if started with @c --chroot . */ static void set_root(const char *path) @@ -2544,7 +2572,7 @@ static MYSQL_SOCKET activate_tcp_port(uint port) my_snprintf(port_buf, NI_MAXSERV, "%d", port); error= getaddrinfo(real_bind_addr_str, port_buf, &hints, &ai); - if (error != 0) + if (unlikely(error != 0)) { DBUG_PRINT("error",("Got error: %d from getaddrinfo()", error)); @@ -2693,6 +2721,9 @@ static void network_init(void) if (MYSQL_CALLBACK_ELSE(thread_scheduler, init, (), 0)) unireg_abort(1); /* purecov: inspected */ + if (init_proxy_protocol_networks(my_proxy_protocol_networks)) + unireg_abort(1); + set_ports(); if (report_port == 0) @@ -2713,7 +2744,7 @@ static void network_init(void) #ifdef _WIN32 /* create named pipe */ - if (Service.IsNT() && mysqld_unix_port[0] && !opt_bootstrap && + if (mysqld_unix_port[0] && !opt_bootstrap && opt_enable_named_pipe) { @@ -2903,16 +2934,17 @@ void unlink_thd(THD *thd) DBUG_ENTER("unlink_thd"); DBUG_PRINT("enter", ("thd: %p", thd)); + thd->cleanup(); + thd->add_status_to_global(); + unlink_not_visible_thd(thd); + /* Do not decrement when its wsrep system thread. wsrep_applier is set for applier as well as rollbacker threads. */ if (IF_WSREP(!thd->wsrep_applier, 1)) dec_connection_count(thd->scheduler); - thd->cleanup(); - thd->add_status_to_global(); - unlink_not_visible_thd(thd); thd->free_connection(); DBUG_VOID_RETURN; @@ -2950,13 +2982,11 @@ static bool cache_thread(THD *thd) DBUG_PRINT("info", ("Adding thread to cache")); cached_thread_count++; -#ifdef HAVE_PSI_THREAD_INTERFACE /* Delete the instrumentation for the job that just completed, before parking this pthread in the cache (blocked on COND_thread_cache). */ - PSI_THREAD_CALL(delete_current_thread)(); -#endif + PSI_CALL_delete_current_thread(); #ifndef DBUG_OFF while (_db_is_pushed_()) @@ -3007,15 +3037,13 @@ static bool cache_thread(THD *thd) */ thd->store_globals(); -#ifdef HAVE_PSI_THREAD_INTERFACE /* Create new instrumentation for the new THD job, and attach it to this running pthread. */ - PSI_thread *psi= PSI_THREAD_CALL(new_thread)(key_thread_one_connection, + PSI_thread *psi= PSI_CALL_new_thread(key_thread_one_connection, thd, thd->thread_id); - PSI_THREAD_CALL(set_thread)(psi); -#endif + PSI_CALL_set_thread(psi); /* reset abort flag for the thread */ thd->mysys_var->abort= 0; @@ -3332,6 +3360,20 @@ static size_t my_setstacksize(pthread_attr_t *attr, size_t stacksize) } #endif +#ifdef DBUG_ASSERT_AS_PRINTF +extern "C" void +mariadb_dbug_assert_failed(const char *assert_expr, const char *file, + unsigned long line) +{ + fprintf(stderr, "Warning: assertion failed: %s at %s line %lu\n", + assert_expr, file, line); + if (opt_stack_trace) + { + fprintf(stderr, "Attempting backtrace to find out the reason for the assert:\n"); + my_print_stacktrace(NULL, (ulong) my_thread_stack_size, 1); + } +} +#endif /* DBUG_ASSERT_AS_PRINT */ #if !defined(__WIN__) #ifndef SA_RESETHAND @@ -3433,8 +3475,9 @@ static void start_signal_handler(void) (void) my_setstacksize(&thr_attr,my_thread_stack_size); mysql_mutex_lock(&LOCK_start_thread); - if ((error= mysql_thread_create(key_thread_signal_hand, - &signal_thread, &thr_attr, signal_hand, 0))) + if (unlikely((error= mysql_thread_create(key_thread_signal_hand, + &signal_thread, &thr_attr, + signal_hand, 0)))) { sql_print_error("Can't create interrupt-thread (error %d, errno: %d)", error,errno); @@ -3532,16 +3575,14 @@ pthread_handler_t signal_hand(void *arg __attribute__((unused))) if (!abort_loop) { abort_loop=1; // mark abort for threads -#ifdef HAVE_PSI_THREAD_INTERFACE /* Delete the instrumentation for the signal thread */ - PSI_THREAD_CALL(delete_current_thread)(); -#endif + PSI_CALL_delete_current_thread(); #ifdef USE_ONE_SIGNAL_HAND pthread_t tmp; - if ((error= mysql_thread_create(0, /* Not instrumented */ - &tmp, &connection_attrib, - kill_server_thread, - (void*) &sig))) + if (unlikely((error= mysql_thread_create(0, /* Not instrumented */ + &tmp, &connection_attrib, + kill_server_thread, + (void*) &sig)))) sql_print_error("Can't create thread to kill server (errno= %d)", error); #else @@ -3633,9 +3674,9 @@ void my_message_sql(uint error, const char *str, myf MyFlags) func= sql_print_error; } - if (thd) + if (likely(thd)) { - if (MyFlags & ME_FATALERROR) + if (unlikely(MyFlags & ME_FATALERROR)) thd->is_fatal_error= 1; (void) thd->raise_condition(error, NULL, level, str); } @@ -3645,7 +3686,7 @@ void my_message_sql(uint error, const char *str, myf MyFlags) /* When simulating OOM, skip writing to error log to avoid mtr errors */ DBUG_EXECUTE_IF("simulate_out_of_memory", DBUG_VOID_RETURN;); - if (!thd || thd->log_all_errors || (MyFlags & ME_NOREFRESH)) + if (unlikely(!thd) || thd->log_all_errors || (MyFlags & ME_NOREFRESH)) (*func)("%s: %s", my_progname_short, str); /* purecov: inspected */ DBUG_VOID_RETURN; } @@ -3777,6 +3818,7 @@ SHOW_VAR com_status_vars[]= { {"alter_function", STMT_STATUS(SQLCOM_ALTER_FUNCTION)}, {"alter_procedure", STMT_STATUS(SQLCOM_ALTER_PROCEDURE)}, {"alter_server", STMT_STATUS(SQLCOM_ALTER_SERVER)}, + {"alter_sequence", STMT_STATUS(SQLCOM_ALTER_SEQUENCE)}, {"alter_table", STMT_STATUS(SQLCOM_ALTER_TABLE)}, {"alter_tablespace", STMT_STATUS(SQLCOM_ALTER_TABLESPACE)}, {"alter_user", STMT_STATUS(SQLCOM_ALTER_USER)}, @@ -3795,8 +3837,11 @@ SHOW_VAR com_status_vars[]= { {"create_event", STMT_STATUS(SQLCOM_CREATE_EVENT)}, {"create_function", STMT_STATUS(SQLCOM_CREATE_SPFUNCTION)}, {"create_index", STMT_STATUS(SQLCOM_CREATE_INDEX)}, + {"create_package", STMT_STATUS(SQLCOM_CREATE_PACKAGE)}, + {"create_package_body", STMT_STATUS(SQLCOM_CREATE_PACKAGE_BODY)}, {"create_procedure", STMT_STATUS(SQLCOM_CREATE_PROCEDURE)}, {"create_role", STMT_STATUS(SQLCOM_CREATE_ROLE)}, + {"create_sequence", STMT_STATUS(SQLCOM_CREATE_SEQUENCE)}, {"create_server", STMT_STATUS(SQLCOM_CREATE_SERVER)}, {"create_table", STMT_STATUS(SQLCOM_CREATE_TABLE)}, {"create_temporary_table", COM_STATUS(com_create_tmp_table)}, @@ -3813,8 +3858,11 @@ SHOW_VAR com_status_vars[]= { {"drop_function", STMT_STATUS(SQLCOM_DROP_FUNCTION)}, {"drop_index", STMT_STATUS(SQLCOM_DROP_INDEX)}, {"drop_procedure", STMT_STATUS(SQLCOM_DROP_PROCEDURE)}, + {"drop_package", STMT_STATUS(SQLCOM_DROP_PACKAGE)}, + {"drop_package_body", STMT_STATUS(SQLCOM_DROP_PACKAGE_BODY)}, {"drop_role", STMT_STATUS(SQLCOM_DROP_ROLE)}, {"drop_server", STMT_STATUS(SQLCOM_DROP_SERVER)}, + {"drop_sequence", STMT_STATUS(SQLCOM_DROP_SEQUENCE)}, {"drop_table", STMT_STATUS(SQLCOM_DROP_TABLE)}, {"drop_temporary_table", COM_STATUS(com_drop_tmp_table)}, {"drop_trigger", STMT_STATUS(SQLCOM_DROP_TRIGGER)}, @@ -3868,6 +3916,8 @@ SHOW_VAR com_status_vars[]= { {"show_create_db", STMT_STATUS(SQLCOM_SHOW_CREATE_DB)}, {"show_create_event", STMT_STATUS(SQLCOM_SHOW_CREATE_EVENT)}, {"show_create_func", STMT_STATUS(SQLCOM_SHOW_CREATE_FUNC)}, + {"show_create_package", STMT_STATUS(SQLCOM_SHOW_CREATE_PACKAGE)}, + {"show_create_package_body",STMT_STATUS(SQLCOM_SHOW_CREATE_PACKAGE_BODY)}, {"show_create_proc", STMT_STATUS(SQLCOM_SHOW_CREATE_PROC)}, {"show_create_table", STMT_STATUS(SQLCOM_SHOW_CREATE)}, {"show_create_trigger", STMT_STATUS(SQLCOM_SHOW_CREATE_TRIGGER)}, @@ -3889,6 +3939,11 @@ SHOW_VAR com_status_vars[]= { {"show_keys", STMT_STATUS(SQLCOM_SHOW_KEYS)}, {"show_master_status", STMT_STATUS(SQLCOM_SHOW_MASTER_STAT)}, {"show_open_tables", STMT_STATUS(SQLCOM_SHOW_OPEN_TABLES)}, + {"show_package_status", STMT_STATUS(SQLCOM_SHOW_STATUS_PACKAGE)}, +#ifndef DBUG_OFF + {"show_package_body_code", STMT_STATUS(SQLCOM_SHOW_PACKAGE_BODY_CODE)}, +#endif + {"show_package_body_status", STMT_STATUS(SQLCOM_SHOW_STATUS_PACKAGE_BODY)}, {"show_plugins", STMT_STATUS(SQLCOM_SHOW_PLUGINS)}, {"show_privileges", STMT_STATUS(SQLCOM_SHOW_PRIVILEGES)}, #ifndef DBUG_OFF @@ -4033,9 +4088,11 @@ static void my_malloc_size_cb_func(long long size, my_bool is_thread_specific) (longlong) thd->status_var.local_memory_used, size)); thd->status_var.local_memory_used+= size; + set_if_bigger(thd->status_var.max_local_memory_used, + thd->status_var.local_memory_used); if (size > 0 && thd->status_var.local_memory_used > (int64)thd->variables.max_mem_used && - !thd->killed && !thd->get_stmt_da()->is_set()) + likely(!thd->killed) && !thd->get_stmt_da()->is_set()) { /* Ensure we don't get called here again */ char buf[50], *buf2; @@ -4131,7 +4188,17 @@ static int init_common_variables() #ifdef SAFEMALLOC sf_malloc_dbug_id= mariadb_dbug_id; -#endif +#endif /* SAFEMALLOC */ +#ifdef DBUG_ASSERT_AS_PRINTF + my_dbug_assert_failed= mariadb_dbug_assert_failed; +#endif /* DBUG_ASSERT_AS_PRINTF */ + + if (!(type_handler_data= new Type_handler_data) || + type_handler_data->init()) + { + sql_perror("Could not allocate type_handler_data"); + return 1; + } max_system_variables.pseudo_thread_id= ~(my_thread_id) 0; server_start_time= flush_status_time= my_time(0); @@ -4193,10 +4260,12 @@ static int init_common_variables() constructor (called before main()). */ mysql_bin_log.set_psi_keys(key_BINLOG_LOCK_index, - key_BINLOG_update_cond, + key_BINLOG_COND_relay_log_updated, + key_BINLOG_COND_bin_log_updated, key_file_binlog, key_file_binlog_index, - key_BINLOG_COND_queue_busy); + key_BINLOG_COND_queue_busy, + key_LOCK_binlog_end_pos); #endif /* @@ -4246,12 +4315,13 @@ static int init_common_variables() (except in the embedded server, where the default continues to be MyISAM) */ -#if defined(WITH_INNOBASE_STORAGE_ENGINE) || defined(WITH_XTRADB_STORAGE_ENGINE) +#if defined(WITH_INNOBASE_STORAGE_ENGINE) default_storage_engine= const_cast<char *>("InnoDB"); #else default_storage_engine= const_cast<char *>("MyISAM"); #endif default_tmp_storage_engine= NULL; + gtid_pos_auto_engines= const_cast<char *>(""); /* Add server status variables to the dynamic list of @@ -4681,6 +4751,8 @@ static int init_common_variables() return 1; } + global_system_variables.in_subquery_conversion_threshold= IN_SUBQUERY_CONVERSION_THRESHOLD; + return 0; } @@ -4925,7 +4997,7 @@ static int init_default_storage_engine_impl(const char *opt_name, return 0; } - LEX_STRING name= { engine_name, strlen(engine_name) }; + LEX_CSTRING name= { engine_name, strlen(engine_name) }; plugin_ref plugin; handlerton *hton; if ((plugin= ha_resolve_by_name(0, &name, false))) @@ -4959,6 +5031,34 @@ static int init_default_storage_engine_impl(const char *opt_name, return 0; } + +static int +init_gtid_pos_auto_engines(void) +{ + plugin_ref *plugins; + + /* + For the command-line option --gtid_pos_auto_engines, we allow (and ignore) + engines that are unknown. This is convenient, since it allows to set + default auto-create engines that might not be used by particular users. + The option sets a list of storage engines that will have gtid position + table auto-created for them if needed. And if the engine is not available, + then it will certainly not be needed. + */ + if (gtid_pos_auto_engines) + plugins= resolve_engine_list(NULL, gtid_pos_auto_engines, + strlen(gtid_pos_auto_engines), false, false); + else + plugins= resolve_engine_list(NULL, "", 0, false, false); + if (!plugins) + return 1; + mysql_mutex_lock(&LOCK_global_system_variables); + opt_gtid_pos_auto_plugins= plugins; + mysql_mutex_unlock(&LOCK_global_system_variables); + return 0; +} + + static int init_server_components() { DBUG_ENTER("init_server_components"); @@ -5076,13 +5176,6 @@ static int init_server_components() xid_cache_init(); - /* - initialize delegates for extension observers, errors have already - been reported in the function - */ - if (delegates_init()) - unireg_abort(1); - /* need to configure logging before initializing storage engines */ if (!opt_bin_log_used && !WSREP_ON) { @@ -5230,10 +5323,7 @@ static int init_server_components() { unireg_abort(1); } - } - if (opt_bin_log) - { log_bin_basename= rpl_make_log_name(opt_bin_logname, pidfile_name, opt_bin_logname ? "" : "-bin"); @@ -5278,7 +5368,7 @@ static int init_server_components() init_global_index_stats(); /* Allow storage engine to give real error messages */ - if (ha_init_errors()) + if (unlikely(ha_init_errors())) DBUG_RETURN(1); tc_log= 0; // ha_initialize_handlerton() needs that @@ -5292,6 +5382,19 @@ static int init_server_components() } plugins_are_initialized= TRUE; /* Don't separate from init function */ +#ifdef HAVE_REPLICATION + /* + Semisync is not required by other components, which justifies its + initialization at this point when thread specific memory is also available. + */ + if (repl_semisync_master.init_object() || + repl_semisync_slave.init_object()) + { + sql_print_error("Could not initialize semisync."); + unireg_abort(1); + } +#endif + #ifndef EMBEDDED_LIBRARY { if (Session_tracker::server_boot_verify(system_charset_info)) @@ -5370,7 +5473,7 @@ static int init_server_components() else { /* fall back to the log files if tables are not present */ - LEX_STRING csv_name={C_STRING_WITH_LEN("csv")}; + LEX_CSTRING csv_name={STRING_WITH_LEN("csv")}; if (!plugin_is_ready(&csv_name, MYSQL_STORAGE_ENGINE_PLUGIN)) { /* purecov: begin inspected */ @@ -5402,6 +5505,9 @@ static int init_server_components() if (init_default_storage_engine(enforced_storage_engine, enforced_table_plugin)) unireg_abort(1); + if (init_gtid_pos_auto_engines()) + unireg_abort(1); + #ifdef USE_ARIA_FOR_TMP_TABLES if (!ha_storage_engine_is_enabled(maria_hton) && !opt_bootstrap) { @@ -5449,7 +5555,7 @@ static int init_server_components() error= mysql_bin_log.open(opt_bin_logname, LOG_BIN, 0, 0, WRITE_CACHE, max_binlog_size, 0, TRUE); mysql_mutex_unlock(log_lock); - if (error) + if (unlikely(error)) unireg_abort(1); } @@ -5483,7 +5589,7 @@ static int init_server_components() else error= mlockall(MCL_CURRENT); - if (error) + if (unlikely(error)) { if (global_system_variables.log_warnings) sql_print_warning("Failed to lock memory. Errno: %d\n",errno); @@ -5515,9 +5621,9 @@ static void create_shutdown_thread() hEventShutdown=CreateEvent(0, FALSE, FALSE, shutdown_event_name); pthread_t hThread; int error; - if ((error= mysql_thread_create(key_thread_handle_shutdown, - &hThread, &connection_attrib, - handle_shutdown, 0))) + if (unlikely((error= mysql_thread_create(key_thread_handle_shutdown, + &hThread, &connection_attrib, + handle_shutdown, 0)))) sql_print_warning("Can't create thread to handle shutdown requests" " (errno= %d)", error); @@ -5616,8 +5722,8 @@ static void test_lc_time_sz() DBUG_ENTER("test_lc_time_sz"); for (MY_LOCALE **loc= my_locales; *loc; loc++) { - uint max_month_len= 0; - uint max_day_len = 0; + size_t max_month_len= 0; + size_t max_day_len= 0; for (const char **month= (*loc)->month_names->type_names; *month; month++) { set_if_bigger(max_month_len, @@ -5768,8 +5874,8 @@ int mysqld_main(int argc, char **argv) */ init_server_psi_keys(); /* Instrument the main thread */ - PSI_thread *psi= PSI_THREAD_CALL(new_thread)(key_thread_main, NULL, 0); - PSI_THREAD_CALL(set_thread)(psi); + PSI_thread *psi= PSI_CALL_new_thread(key_thread_main, NULL, 0); + PSI_CALL_set_thread(psi); /* Now that some instrumentation is in place, @@ -6070,6 +6176,9 @@ int mysqld_main(int argc, char **argv) MYSQL_SET_STAGE(0 ,__FILE__, __LINE__); + /* Memory used when everything is setup */ + start_memory_used= global_status_var.global_memory_used; + #if defined(_WIN32) || defined(HAVE_SMEM) handle_connections_methods(); #else @@ -6087,13 +6196,11 @@ int mysqld_main(int argc, char **argv) mysql_mutex_unlock(&LOCK_start_thread); #endif /* __WIN__ */ -#ifdef HAVE_PSI_THREAD_INTERFACE /* Disable the main thread instrumentation, to avoid recording events during the shutdown. */ - PSI_THREAD_CALL(delete_current_thread)(); -#endif + PSI_CALL_delete_current_thread(); /* Wait until cleanup is done */ mysql_mutex_lock(&LOCK_thread_count); @@ -6102,7 +6209,7 @@ int mysqld_main(int argc, char **argv) mysql_mutex_unlock(&LOCK_thread_count); #if defined(__WIN__) && !defined(EMBEDDED_LIBRARY) - if (Service.IsNT() && start_mode) + if (start_mode) Service.Stop(); else { @@ -6127,10 +6234,10 @@ int mysqld_main(int argc, char **argv) ****************************************************************************/ #if defined(__WIN__) && !defined(EMBEDDED_LIBRARY) -int mysql_service(void *p) +void mysql_service(void *p) { if (my_thread_init()) - return 1; + abort(); if (use_opt_args) win_main(opt_argc, opt_argv); @@ -6138,7 +6245,6 @@ int mysql_service(void *p) win_main(Service.my_argc, Service.my_argv); my_thread_end(); - return 0; } @@ -6189,7 +6295,7 @@ default_service_handling(char **argv, the option name) should be quoted if it contains a string. */ *pos++= ' '; - if (opt_delim= strchr(extra_opt, '=')) + if ((opt_delim= strchr(extra_opt, '='))) { size_t length= ++opt_delim - extra_opt; pos= strnmov(pos, extra_opt, length); @@ -6245,87 +6351,86 @@ int mysqld_main(int argc, char **argv) return 1; } - if (Service.GetOS()) /* true NT family */ + + char file_path[FN_REFLEN]; + my_path(file_path, argv[0], ""); /* Find name in path */ + fn_format(file_path,argv[0],file_path,"", MY_REPLACE_DIR | MY_UNPACK_FILENAME | MY_RESOLVE_SYMLINKS); + + if (argc == 2) { - char file_path[FN_REFLEN]; - my_path(file_path, argv[0], ""); /* Find name in path */ - fn_format(file_path,argv[0],file_path,"", - MY_REPLACE_DIR | MY_UNPACK_FILENAME | MY_RESOLVE_SYMLINKS); + if (!default_service_handling(argv, MYSQL_SERVICENAME, MYSQL_SERVICENAME, + file_path, "", NULL)) + return 0; - if (argc == 2) - { - if (!default_service_handling(argv, MYSQL_SERVICENAME, MYSQL_SERVICENAME, - file_path, "", NULL)) - return 0; - if (Service.IsService(argv[1])) /* Start an optional service */ - { - /* - Only add the service name to the groups read from the config file - if it's not "MySQL". (The default service name should be 'mysqld' - but we started a bad tradition by calling it MySQL from the start - and we are now stuck with it. - */ - if (my_strcasecmp(system_charset_info, argv[1],"mysql")) - load_default_groups[load_default_groups_sz-2]= argv[1]; - start_mode= 1; - Service.Init(argv[1], mysql_service); - return 0; - } - } - else if (argc == 3) /* install or remove any optional service */ - { - if (!default_service_handling(argv, argv[2], argv[2], file_path, "", - NULL)) - return 0; - if (Service.IsService(argv[2])) - { - /* - mysqld was started as - mysqld --defaults-file=my_path\my.ini service-name - */ - use_opt_args=1; - opt_argc= 2; // Skip service-name - opt_argv=argv; - start_mode= 1; - if (my_strcasecmp(system_charset_info, argv[2],"mysql")) - load_default_groups[load_default_groups_sz-2]= argv[2]; - Service.Init(argv[2], mysql_service); - return 0; - } - } - else if (argc == 4 || argc == 5) + if (Service.IsService(argv[1])) /* Start an optional service */ { /* - This may seem strange, because we handle --local-service while - preserving 4.1's behavior of allowing any one other argument that is - passed to the service on startup. (The assumption is that this is - --defaults-file=file, but that was not enforced in 4.1, so we don't - enforce it here.) + Only add the service name to the groups read from the config file + if it's not "MySQL". (The default service name should be 'mysqld' + but we started a bad tradition by calling it MySQL from the start + and we are now stuck with it. */ - const char *extra_opt= NullS; - const char *account_name = NullS; - int index; - for (index = 3; index < argc; index++) - { - if (!strcmp(argv[index], "--local-service")) - account_name= "NT AUTHORITY\\LocalService"; - else - extra_opt= argv[index]; - } - - if (argc == 4 || account_name) - if (!default_service_handling(argv, argv[2], argv[2], file_path, - extra_opt, account_name)) - return 0; + if (my_strcasecmp(system_charset_info, argv[1],"mysql")) + load_default_groups[load_default_groups_sz-2]= argv[1]; + start_mode= 1; + Service.Init(argv[1], mysql_service); + return 0; } - else if (argc == 1 && Service.IsService(MYSQL_SERVICENAME)) + } + else if (argc == 3) /* install or remove any optional service */ + { + if (!default_service_handling(argv, argv[2], argv[2], file_path, "", + NULL)) + return 0; + if (Service.IsService(argv[2])) { - /* start the default service */ + /* + mysqld was started as + mysqld --defaults-file=my_path\my.ini service-name + */ + use_opt_args=1; + opt_argc= 2; // Skip service-name + opt_argv=argv; start_mode= 1; - Service.Init(MYSQL_SERVICENAME, mysql_service); + if (my_strcasecmp(system_charset_info, argv[2],"mysql")) + load_default_groups[load_default_groups_sz-2]= argv[2]; + Service.Init(argv[2], mysql_service); return 0; } } + else if (argc == 4 || argc == 5) + { + /* + This may seem strange, because we handle --local-service while + preserving 4.1's behavior of allowing any one other argument that is + passed to the service on startup. (The assumption is that this is + --defaults-file=file, but that was not enforced in 4.1, so we don't + enforce it here.) + */ + const char *extra_opt= NullS; + const char *account_name = NullS; + int index; + for (index = 3; index < argc; index++) + { + if (!strcmp(argv[index], "--local-service")) + account_name= "NT AUTHORITY\\LocalService"; + else + extra_opt= argv[index]; + } + + if (argc == 4 || account_name) + if (!default_service_handling(argv, argv[2], argv[2], file_path, + extra_opt, account_name)) + return 0; + } + else if (argc == 1 && Service.IsService(MYSQL_SERVICENAME)) + { + /* start the default service */ + start_mode= 1; + Service.Init(MYSQL_SERVICENAME, mysql_service); + return 0; + } + /* Start as standalone server */ Service.my_argc=argc; Service.my_argv=argv; @@ -6366,6 +6471,7 @@ static void bootstrap(MYSQL_FILE *file) sql_print_warning("Can't create thread to handle bootstrap (errno= %d)", error); bootstrap_error=-1; + delete thd; DBUG_VOID_RETURN; } /* Wait for thread to die */ @@ -7245,9 +7351,6 @@ struct my_option my_long_options[]= {"autocommit", 0, "Set default value for autocommit (0 or 1)", &opt_autocommit, &opt_autocommit, 0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, NULL}, - {"bind-address", 0, "IP address to bind to.", - &my_bind_addr_str, &my_bind_addr_str, 0, GET_STR, - REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"binlog-do-db", OPT_BINLOG_DO_DB, "Tells the master it should log updates for the specified database, " "and exclude all others not explicitly mentioned.", @@ -7261,7 +7364,7 @@ struct my_option my_long_options[]= "The value has to be a multiple of 256.", &opt_binlog_rows_event_max_size, &opt_binlog_rows_event_max_size, 0, GET_ULONG, REQUIRED_ARG, - /* def_value */ 8192, /* min_value */ 256, /* max_value */ ULONG_MAX, + /* def_value */ 8192, /* min_value */ 256, /* max_value */ UINT_MAX32-1, /* sub_size */ 0, /* block_size */ 256, /* app_type */ 0 }, @@ -7332,13 +7435,6 @@ struct my_option my_long_options[]= &max_binlog_dump_events, &max_binlog_dump_events, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif /* HAVE_REPLICATION */ -#ifdef SAFE_MUTEX - {"debug-mutex-deadlock-detector", 0, - "Enable checking of wrong mutex usage.", - &safe_mutex_deadlock_detector, - &safe_mutex_deadlock_detector, - 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, -#endif {"debug-no-sync", 0, "Disables system sync calls. Only for running tests or debugging!", &my_disable_sync, &my_disable_sync, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -7405,6 +7501,14 @@ struct my_option my_long_options[]= "Set up signals usable for debugging. Deprecated, use --debug-gdb instead.", &opt_debugging, &opt_debugging, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"gtid-pos-auto-engines", 0, + "List of engines for which to automatically create a " + "mysql.gtid_slave_pos_ENGINE table, if a transaction using that engine " + "is replicated. This can be used to avoid introducing cross-engine " + "transactions, if engines are used different from that used by table " + "mysql.gtid_slave_pos", + >id_pos_auto_engines, 0, 0, GET_STR, REQUIRED_ARG, + 0, 0, 0, 0, 0, 0 }, #ifdef HAVE_LARGE_PAGE_OPTION {"super-large-pages", 0, "Enable support for super large pages.", &opt_super_large_pages, &opt_super_large_pages, 0, @@ -7702,6 +7806,7 @@ struct my_option my_long_options[]= MYSQL_SUGGEST_ANALOG_OPTION("max-binlog-dump-events", "--debug-max-binlog-dump-events"), MYSQL_SUGGEST_ANALOG_OPTION("sporadic-binlog-dump-fail", "--debug-sporadic-binlog-dump-fail"), MYSQL_COMPATIBILITY_OPTION("new"), + MYSQL_COMPATIBILITY_OPTION("show_compatibility_56"), /* The following options were added after 5.6.10 */ MYSQL_TO_BE_IMPLEMENTED_OPTION("rpl-stop-slave-timeout"), @@ -7802,7 +7907,7 @@ static int show_slaves_running(THD *thd, SHOW_VAR *var, char *buff) var->type= SHOW_LONGLONG; var->value= buff; - *((longlong *)buff)= any_slave_sql_running(); + *((longlong *)buff)= any_slave_sql_running(false); return 0; } @@ -8174,6 +8279,27 @@ static int show_ssl_get_cipher_list(THD *thd, SHOW_VAR *var, char *buff, return 0; } +#define SHOW_FNAME(name) \ + rpl_semi_sync_master_show_##name + +#define DEF_SHOW_FUNC(name, show_type) \ + static int SHOW_FNAME(name)(MYSQL_THD thd, SHOW_VAR *var, char *buff) \ + { \ + repl_semisync_master.set_export_stats(); \ + var->type= show_type; \ + var->value= (char *)&rpl_semi_sync_master_##name; \ + return 0; \ + } + +DEF_SHOW_FUNC(status, SHOW_BOOL) +DEF_SHOW_FUNC(clients, SHOW_LONG) +DEF_SHOW_FUNC(wait_sessions, SHOW_LONG) +DEF_SHOW_FUNC(trx_wait_time, SHOW_LONGLONG) +DEF_SHOW_FUNC(trx_wait_num, SHOW_LONGLONG) +DEF_SHOW_FUNC(net_wait_time, SHOW_LONGLONG) +DEF_SHOW_FUNC(net_wait_num, SHOW_LONGLONG) +DEF_SHOW_FUNC(avg_net_wait_time, SHOW_LONG) +DEF_SHOW_FUNC(avg_trx_wait_time, SHOW_LONG) #ifdef HAVE_YASSL @@ -8404,6 +8530,8 @@ SHOW_VAR status_vars[]= { {"Busy_time", (char*) offsetof(STATUS_VAR, busy_time), SHOW_DOUBLE_STATUS}, {"Bytes_received", (char*) offsetof(STATUS_VAR, bytes_received), SHOW_LONGLONG_STATUS}, {"Bytes_sent", (char*) offsetof(STATUS_VAR, bytes_sent), SHOW_LONGLONG_STATUS}, + {"Column_compressions", (char*) offsetof(STATUS_VAR, column_compressions), SHOW_LONG_STATUS}, + {"Column_decompressions", (char*) offsetof(STATUS_VAR, column_decompressions), SHOW_LONG_STATUS}, {"Com", (char*) com_status_vars, SHOW_ARRAY}, {"Compression", (char*) &show_net_compression, SHOW_SIMPLE_FUNC}, {"Connections", (char*) &global_thread_id, SHOW_LONG_NOFLUSH}, @@ -8428,12 +8556,16 @@ SHOW_VAR status_vars[]= { {"Executed_events", (char*) &executed_events, SHOW_LONG_NOFLUSH }, {"Executed_triggers", (char*) offsetof(STATUS_VAR, executed_triggers), SHOW_LONG_STATUS}, {"Feature_check_constraint", (char*) &feature_check_constraint, SHOW_LONG }, + {"Feature_custom_aggregate_functions", (char*) offsetof(STATUS_VAR, feature_custom_aggregate_functions), SHOW_LONG_STATUS}, {"Feature_delay_key_write", (char*) &feature_files_opened_with_delayed_keys, SHOW_LONG }, {"Feature_dynamic_columns", (char*) offsetof(STATUS_VAR, feature_dynamic_columns), SHOW_LONG_STATUS}, {"Feature_fulltext", (char*) offsetof(STATUS_VAR, feature_fulltext), SHOW_LONG_STATUS}, {"Feature_gis", (char*) offsetof(STATUS_VAR, feature_gis), SHOW_LONG_STATUS}, + {"Feature_invisible_columns", (char*) offsetof(STATUS_VAR, feature_invisible_columns), SHOW_LONG_STATUS}, + {"Feature_json", (char*) offsetof(STATUS_VAR, feature_json), SHOW_LONG_STATUS}, {"Feature_locale", (char*) offsetof(STATUS_VAR, feature_locale), SHOW_LONG_STATUS}, {"Feature_subquery", (char*) offsetof(STATUS_VAR, feature_subquery), SHOW_LONG_STATUS}, + {"Feature_system_versioning", (char*) offsetof(STATUS_VAR, feature_system_versioning), SHOW_LONG_STATUS}, {"Feature_timezone", (char*) offsetof(STATUS_VAR, feature_timezone), SHOW_LONG_STATUS}, {"Feature_trigger", (char*) offsetof(STATUS_VAR, feature_trigger), SHOW_LONG_STATUS}, {"Feature_window_functions", (char*) offsetof(STATUS_VAR, feature_window_functions), SHOW_LONG_STATUS}, @@ -8442,7 +8574,7 @@ SHOW_VAR status_vars[]= { {"Handler_commit", (char*) offsetof(STATUS_VAR, ha_commit_count), SHOW_LONG_STATUS}, {"Handler_delete", (char*) offsetof(STATUS_VAR, ha_delete_count), SHOW_LONG_STATUS}, {"Handler_discover", (char*) offsetof(STATUS_VAR, ha_discover_count), SHOW_LONG_STATUS}, - {"Handler_external_lock", (char*) offsetof(STATUS_VAR, ha_external_lock_count), SHOW_LONGLONG_STATUS}, + {"Handler_external_lock", (char*) offsetof(STATUS_VAR, ha_external_lock_count), SHOW_LONG_STATUS}, {"Handler_icp_attempts", (char*) offsetof(STATUS_VAR, ha_icp_attempts), SHOW_LONG_STATUS}, {"Handler_icp_match", (char*) offsetof(STATUS_VAR, ha_icp_match), SHOW_LONG_STATUS}, {"Handler_mrr_init", (char*) offsetof(STATUS_VAR, ha_mrr_init_count), SHOW_LONG_STATUS}, @@ -8461,6 +8593,7 @@ SHOW_VAR status_vars[]= { {"Handler_rollback", (char*) offsetof(STATUS_VAR, ha_rollback_count), SHOW_LONG_STATUS}, {"Handler_savepoint", (char*) offsetof(STATUS_VAR, ha_savepoint_count), SHOW_LONG_STATUS}, {"Handler_savepoint_rollback",(char*) offsetof(STATUS_VAR, ha_savepoint_rollback_count), SHOW_LONG_STATUS}, + {"Handler_tmp_delete", (char*) offsetof(STATUS_VAR, ha_tmp_delete_count), SHOW_LONG_STATUS}, {"Handler_tmp_update", (char*) offsetof(STATUS_VAR, ha_tmp_update_count), SHOW_LONG_STATUS}, {"Handler_tmp_write", (char*) offsetof(STATUS_VAR, ha_tmp_write_count), SHOW_LONG_STATUS}, {"Handler_update", (char*) offsetof(STATUS_VAR, ha_update_count), SHOW_LONG_STATUS}, @@ -8473,6 +8606,7 @@ SHOW_VAR status_vars[]= { {"Master_gtid_wait_time", (char*) offsetof(STATUS_VAR, master_gtid_wait_time), SHOW_LONGLONG_STATUS}, {"Max_used_connections", (char*) &max_used_connections, SHOW_LONG}, {"Memory_used", (char*) &show_memory_used, SHOW_SIMPLE_FUNC}, + {"Memory_used_initial", (char*) &start_memory_used, SHOW_LONGLONG}, {"Not_flushed_delayed_rows", (char*) &delayed_rows_in_use, SHOW_LONG_NOFLUSH}, {"Open_files", (char*) &my_file_opened, SHOW_LONG_NOFLUSH}, {"Open_streams", (char*) &my_stream_opened, SHOW_LONG_NOFLUSH}, @@ -8487,6 +8621,26 @@ SHOW_VAR status_vars[]= { {"Rows_sent", (char*) offsetof(STATUS_VAR, rows_sent), SHOW_LONGLONG_STATUS}, {"Rows_read", (char*) offsetof(STATUS_VAR, rows_read), SHOW_LONGLONG_STATUS}, {"Rows_tmp_read", (char*) offsetof(STATUS_VAR, rows_tmp_read), SHOW_LONGLONG_STATUS}, +#ifdef HAVE_REPLICATION + {"Rpl_semi_sync_master_status", (char*) &SHOW_FNAME(status), SHOW_FUNC}, + {"Rpl_semi_sync_master_clients", (char*) &SHOW_FNAME(clients), SHOW_FUNC}, + {"Rpl_semi_sync_master_yes_tx", (char*) &rpl_semi_sync_master_yes_transactions, SHOW_LONG}, + {"Rpl_semi_sync_master_no_tx", (char*) &rpl_semi_sync_master_no_transactions, SHOW_LONG}, + {"Rpl_semi_sync_master_wait_sessions", (char*) &SHOW_FNAME(wait_sessions), SHOW_FUNC}, + {"Rpl_semi_sync_master_no_times", (char*) &rpl_semi_sync_master_off_times, SHOW_LONG}, + {"Rpl_semi_sync_master_timefunc_failures", (char*) &rpl_semi_sync_master_timefunc_fails, SHOW_LONG}, + {"Rpl_semi_sync_master_wait_pos_backtraverse", (char*) &rpl_semi_sync_master_wait_pos_backtraverse, SHOW_LONG}, + {"Rpl_semi_sync_master_tx_wait_time", (char*) &SHOW_FNAME(trx_wait_time), SHOW_FUNC}, + {"Rpl_semi_sync_master_tx_waits", (char*) &SHOW_FNAME(trx_wait_num), SHOW_FUNC}, + {"Rpl_semi_sync_master_tx_avg_wait_time", (char*) &SHOW_FNAME(avg_trx_wait_time), SHOW_FUNC}, + {"Rpl_semi_sync_master_net_wait_time", (char*) &SHOW_FNAME(net_wait_time), SHOW_FUNC}, + {"Rpl_semi_sync_master_net_waits", (char*) &SHOW_FNAME(net_wait_num), SHOW_FUNC}, + {"Rpl_semi_sync_master_net_avg_wait_time", (char*) &SHOW_FNAME(avg_net_wait_time), SHOW_FUNC}, + {"Rpl_semi_sync_master_request_ack", (char*) &rpl_semi_sync_master_request_ack, SHOW_LONGLONG}, + {"Rpl_semi_sync_master_get_ack", (char*)&rpl_semi_sync_master_get_ack, SHOW_LONGLONG}, + {"Rpl_semi_sync_slave_status", (char*) &rpl_semi_sync_slave_status, SHOW_BOOL}, + {"Rpl_semi_sync_slave_send_ack", (char*) &rpl_semi_sync_slave_send_ack, SHOW_LONGLONG}, +#endif /* HAVE_REPLICATION */ #ifdef HAVE_QUERY_CACHE {"Qcache_free_blocks", (char*) &query_cache.free_memory_blocks, SHOW_LONG_NOFLUSH}, {"Qcache_free_memory", (char*) &query_cache.free_memory, SHOW_LONG_NOFLUSH}, @@ -8563,6 +8717,10 @@ SHOW_VAR status_vars[]= { {"Subquery_cache_miss", (char*) &subquery_cache_miss, SHOW_LONG}, {"Table_locks_immediate", (char*) &locks_immediate, SHOW_LONG}, {"Table_locks_waited", (char*) &locks_waited, SHOW_LONG}, + {"Table_open_cache_active_instances", (char*) &tc_active_instances, SHOW_UINT}, + {"Table_open_cache_hits", (char*) offsetof(STATUS_VAR, table_open_cache_hits), SHOW_LONGLONG_STATUS}, + {"Table_open_cache_misses", (char*) offsetof(STATUS_VAR, table_open_cache_misses), SHOW_LONGLONG_STATUS}, + {"Table_open_cache_overflows", (char*) offsetof(STATUS_VAR, table_open_cache_overflows), SHOW_LONGLONG_STATUS}, #ifdef HAVE_MMAP {"Tc_log_max_pages_used", (char*) &tc_log_max_pages_used, SHOW_LONG}, {"Tc_log_page_size", (char*) &tc_log_page_size, SHOW_LONG_NOFLUSH}, @@ -8575,7 +8733,10 @@ SHOW_VAR status_vars[]= { {"Threads_cached", (char*) &cached_thread_count, SHOW_LONG_NOFLUSH}, {"Threads_connected", (char*) &connection_count, SHOW_INT}, {"Threads_created", (char*) &thread_created, SHOW_LONG_NOFLUSH}, - {"Threads_running", (char*) &thread_running, SHOW_INT}, + {"Threads_running", (char*) offsetof(STATUS_VAR, threads_running), SHOW_UINT32_STATUS}, + {"Transactions_multi_engine", (char*) &transactions_multi_engine, SHOW_LONG}, + {"Rpl_transactions_multi_engine", (char*) &rpl_transactions_multi_engine, SHOW_LONG}, + {"Transactions_gtid_foreign_engine", (char*) &transactions_gtid_foreign_engine, SHOW_LONG}, {"Update_scan", (char*) offsetof(STATUS_VAR, update_scan_count), SHOW_LONG_STATUS}, {"Uptime", (char*) &show_starttime, SHOW_SIMPLE_FUNC}, #ifdef ENABLED_PROFILING @@ -8640,7 +8801,7 @@ static int option_cmp(my_option *a, my_option *b) static void print_help() { MEM_ROOT mem_root; - init_alloc_root(&mem_root, 4096, 4096, MYF(0)); + init_alloc_root(&mem_root, "help", 4096, 4096, MYF(0)); pop_dynamic(&all_options); add_many_options(&all_options, pfs_early_options, @@ -8749,7 +8910,7 @@ static int mysql_init_variables(void) kill_in_progress= 0; cleanup_done= 0; test_flags= select_errors= dropping_tables= ha_open_options=0; - thread_count= thread_running= kill_cached_threads= wake_thread= 0; + thread_count= kill_cached_threads= wake_thread= 0; service_thread_count= 0; slave_open_temp_tables= 0; cached_thread_count= 0; @@ -8819,6 +8980,9 @@ static int mysql_init_variables(void) report_user= report_password = report_host= 0; /* TO BE DELETED */ opt_relay_logname= opt_relaylog_index_name= 0; slave_retried_transactions= 0; + transactions_multi_engine= 0; + rpl_transactions_multi_engine= 0; + transactions_gtid_foreign_engine= 0; log_bin_basename= NULL; log_bin_index= NULL; @@ -8845,7 +9009,7 @@ static int mysql_init_variables(void) #if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY) have_ssl=SHOW_OPTION_YES; -#if HAVE_YASSL +#if defined(HAVE_YASSL) have_openssl= SHOW_OPTION_NO; #else have_openssl= SHOW_OPTION_YES; @@ -8973,12 +9137,12 @@ mysqld_get_one_option(int optid, const struct my_option *opt, char *argument) opt->name); break; case OPT_MYSQL_COMPATIBILITY: - sql_print_warning("'%s' is MySQL 5.6 compatible option. Not used or needed " - "in MariaDB.", opt->name); + sql_print_warning("'%s' is MySQL 5.6 / 5.7 compatible option. Not used or " + "needed in MariaDB.", opt->name); break; case OPT_MYSQL_TO_BE_IMPLEMENTED: - sql_print_warning("'%s' is MySQL 5.6 compatible option. To be implemented " - "in later versions.", opt->name); + sql_print_warning("'%s' is MySQL 5.6 / 5.7 compatible option. To be " + "implemented in later versions.", opt->name); break; case 'a': SYSVAR_AUTOSIZE(global_system_variables.sql_mode, MODE_ANSI); @@ -9397,7 +9561,7 @@ mysql_getopt_value(const char *name, uint length, case OPT_KEY_CACHE_CHANGED_BLOCKS_HASH_SIZE: { KEY_CACHE *key_cache; - if (!(key_cache= get_or_create_key_cache(name, length))) + if (unlikely(!(key_cache= get_or_create_key_cache(name, length)))) { if (error) *error= EXIT_OUT_OF_MEMORY; @@ -9527,17 +9691,6 @@ static int get_options(int *argc_ptr, char ***argv_ptr) global_system_variables.max_allowed_packet); } -#if MYSQL_VERSION_ID > 101001 - /* - TIMESTAMP columns get implicit DEFAULT values when - --explicit_defaults_for_timestamp is not set. - */ - if (!opt_help && !opt_explicit_defaults_for_timestamp) - sql_print_warning("TIMESTAMP with implicit DEFAULT value is deprecated. " - "Please use --explicit_defaults_for_timestamp server " - "option (see documentation for more details)."); -#endif - if (log_error_file_ptr != disabled_my_option) opt_error_log= 1; else @@ -9566,8 +9719,10 @@ static int get_options(int *argc_ptr, char ***argv_ptr) flush_time= 0; #ifdef HAVE_REPLICATION - if (opt_slave_skip_errors) - init_slave_skip_errors(opt_slave_skip_errors); + if (init_slave_skip_errors(opt_slave_skip_errors)) + return 1; + if (init_slave_transaction_retry_errors(opt_slave_transaction_retry_errors)) + return 1; #endif if (global_system_variables.max_join_size == HA_POS_ERROR) @@ -9734,7 +9889,7 @@ static int get_options(int *argc_ptr, char ***argv_ptr) /* Ensure that some variables are not set higher than needed */ if (thread_cache_size > max_connections) SYSVAR_AUTOSIZE(thread_cache_size, max_connections); - + return 0; } @@ -9882,7 +10037,7 @@ static int fix_paths(void) my_realpath(mysql_unpacked_real_data_home, mysql_real_data_home, MYF(0)); mysql_unpacked_real_data_home_len= - (int) strlen(mysql_unpacked_real_data_home); + strlen(mysql_unpacked_real_data_home); if (mysql_unpacked_real_data_home[mysql_unpacked_real_data_home_len-1] == FN_LIBCHAR) --mysql_unpacked_real_data_home_len; @@ -10104,108 +10259,118 @@ static PSI_file_info all_server_files[]= }; #endif /* HAVE_PSI_INTERFACE */ -PSI_stage_info stage_after_apply_event= { 0, "after apply log event", 0}; +PSI_stage_info stage_after_apply_event= { 0, "After apply log event", 0}; PSI_stage_info stage_after_create= { 0, "After create", 0}; PSI_stage_info stage_after_opening_tables= { 0, "After opening tables", 0}; PSI_stage_info stage_after_table_lock= { 0, "After table lock", 0}; -PSI_stage_info stage_allocating_local_table= { 0, "allocating local table", 0}; -PSI_stage_info stage_alter_inplace_prepare= { 0, "preparing for alter table", 0}; -PSI_stage_info stage_alter_inplace= { 0, "altering table", 0}; -PSI_stage_info stage_alter_inplace_commit= { 0, "committing alter table to storage engine", 0}; -PSI_stage_info stage_apply_event= { 0, "apply log event", 0}; +PSI_stage_info stage_allocating_local_table= { 0, "Allocating local table", 0}; +PSI_stage_info stage_alter_inplace_prepare= { 0, "Preparing for alter table", 0}; +PSI_stage_info stage_alter_inplace= { 0, "Altering table", 0}; +PSI_stage_info stage_alter_inplace_commit= { 0, "Committing alter table to storage engine", 0}; +PSI_stage_info stage_apply_event= { 0, "Apply log event", 0}; PSI_stage_info stage_changing_master= { 0, "Changing master", 0}; PSI_stage_info stage_checking_master_version= { 0, "Checking master version", 0}; -PSI_stage_info stage_checking_permissions= { 0, "checking permissions", 0}; -PSI_stage_info stage_checking_privileges_on_cached_query= { 0, "checking privileges on cached query", 0}; -PSI_stage_info stage_checking_query_cache_for_query= { 0, "checking query cache for query", 0}; -PSI_stage_info stage_cleaning_up= { 0, "cleaning up", 0}; -PSI_stage_info stage_closing_tables= { 0, "closing tables", 0}; +PSI_stage_info stage_checking_permissions= { 0, "Checking permissions", 0}; +PSI_stage_info stage_checking_privileges_on_cached_query= { 0, "Checking privileges on cached query", 0}; +PSI_stage_info stage_checking_query_cache_for_query= { 0, "Checking query cache for query", 0}; +PSI_stage_info stage_cleaning_up= { 0, "Reset for next command", 0}; +PSI_stage_info stage_closing_tables= { 0, "Closing tables", 0}; PSI_stage_info stage_connecting_to_master= { 0, "Connecting to master", 0}; -PSI_stage_info stage_converting_heap_to_myisam= { 0, "converting HEAP to " TMP_ENGINE_NAME, 0}; +PSI_stage_info stage_converting_heap_to_myisam= { 0, "Converting HEAP to " TMP_ENGINE_NAME, 0}; PSI_stage_info stage_copying_to_group_table= { 0, "Copying to group table", 0}; PSI_stage_info stage_copying_to_tmp_table= { 0, "Copying to tmp table", 0}; -PSI_stage_info stage_copy_to_tmp_table= { 0, "copy to tmp table", 0}; +PSI_stage_info stage_copy_to_tmp_table= { 0, "Copy to tmp table", 0}; PSI_stage_info stage_creating_delayed_handler= { 0, "Creating delayed handler", 0}; PSI_stage_info stage_creating_sort_index= { 0, "Creating sort index", 0}; -PSI_stage_info stage_creating_table= { 0, "creating table", 0}; +PSI_stage_info stage_creating_table= { 0, "Creating table", 0}; PSI_stage_info stage_creating_tmp_table= { 0, "Creating tmp table", 0}; -PSI_stage_info stage_deleting_from_main_table= { 0, "deleting from main table", 0}; -PSI_stage_info stage_deleting_from_reference_tables= { 0, "deleting from reference tables", 0}; -PSI_stage_info stage_discard_or_import_tablespace= { 0, "discard_or_import_tablespace", 0}; -PSI_stage_info stage_enabling_keys= { 0, "enabling keys", 0}; -PSI_stage_info stage_end= { 0, "end", 0}; -PSI_stage_info stage_executing= { 0, "executing", 0}; +PSI_stage_info stage_deleting_from_main_table= { 0, "Deleting from main table", 0}; +PSI_stage_info stage_deleting_from_reference_tables= { 0, "Deleting from reference tables", 0}; +PSI_stage_info stage_discard_or_import_tablespace= { 0, "Discard_or_import_tablespace", 0}; +PSI_stage_info stage_enabling_keys= { 0, "Enabling keys", 0}; +PSI_stage_info stage_end= { 0, "End of update loop", 0}; +PSI_stage_info stage_executing= { 0, "Executing", 0}; PSI_stage_info stage_execution_of_init_command= { 0, "Execution of init_command", 0}; -PSI_stage_info stage_explaining= { 0, "explaining", 0}; +PSI_stage_info stage_explaining= { 0, "Explaining", 0}; PSI_stage_info stage_finding_key_cache= { 0, "Finding key cache", 0}; PSI_stage_info stage_finished_reading_one_binlog_switching_to_next_binlog= { 0, "Finished reading one binlog; switching to next binlog", 0}; PSI_stage_info stage_flushing_relay_log_and_master_info_repository= { 0, "Flushing relay log and master info repository.", 0}; PSI_stage_info stage_flushing_relay_log_info_file= { 0, "Flushing relay-log info file.", 0}; -PSI_stage_info stage_freeing_items= { 0, "freeing items", 0}; -PSI_stage_info stage_fulltext_initialization= { 0, "FULLTEXT initialization", 0}; -PSI_stage_info stage_got_handler_lock= { 0, "got handler lock", 0}; -PSI_stage_info stage_got_old_table= { 0, "got old table", 0}; -PSI_stage_info stage_init= { 0, "init", 0}; -PSI_stage_info stage_insert= { 0, "insert", 0}; -PSI_stage_info stage_invalidating_query_cache_entries_table= { 0, "invalidating query cache entries (table)", 0}; -PSI_stage_info stage_invalidating_query_cache_entries_table_list= { 0, "invalidating query cache entries (table list)", 0}; +PSI_stage_info stage_freeing_items= { 0, "Freeing items", 0}; +PSI_stage_info stage_fulltext_initialization= { 0, "Fulltext initialization", 0}; +PSI_stage_info stage_got_handler_lock= { 0, "Got handler lock", 0}; +PSI_stage_info stage_got_old_table= { 0, "Got old table", 0}; +PSI_stage_info stage_init= { 0, "Init", 0}; +PSI_stage_info stage_init_update= { 0, "Init for update", 0}; +PSI_stage_info stage_insert= { 0, "Insert", 0}; +PSI_stage_info stage_invalidating_query_cache_entries_table= { 0, "Invalidating query cache entries (table)", 0}; +PSI_stage_info stage_invalidating_query_cache_entries_table_list= { 0, "Invalidating query cache entries (table list)", 0}; PSI_stage_info stage_killing_slave= { 0, "Killing slave", 0}; -PSI_stage_info stage_logging_slow_query= { 0, "logging slow query", 0}; +PSI_stage_info stage_logging_slow_query= { 0, "Logging slow query", 0}; PSI_stage_info stage_making_temp_file_append_before_load_data= { 0, "Making temporary file (append) before replaying LOAD DATA INFILE.", 0}; PSI_stage_info stage_making_temp_file_create_before_load_data= { 0, "Making temporary file (create) before replaying LOAD DATA INFILE.", 0}; -PSI_stage_info stage_manage_keys= { 0, "manage keys", 0}; +PSI_stage_info stage_manage_keys= { 0, "Manage keys", 0}; PSI_stage_info stage_master_has_sent_all_binlog_to_slave= { 0, "Master has sent all binlog to slave; waiting for binlog to be updated", 0}; PSI_stage_info stage_opening_tables= { 0, "Opening tables", 0}; -PSI_stage_info stage_optimizing= { 0, "optimizing", 0}; -PSI_stage_info stage_preparing= { 0, "preparing", 0}; +PSI_stage_info stage_optimizing= { 0, "Optimizing", 0}; +PSI_stage_info stage_preparing= { 0, "Preparing", 0}; PSI_stage_info stage_purging_old_relay_logs= { 0, "Purging old relay logs", 0}; -PSI_stage_info stage_query_end= { 0, "query end", 0}; +PSI_stage_info stage_query_end= { 0, "Query end", 0}; +PSI_stage_info stage_starting_cleanup= { 0, "Starting cleanup", 0}; +PSI_stage_info stage_rollback= { 0, "Rollback", 0}; +PSI_stage_info stage_rollback_implicit= { 0, "Rollback_implicit", 0}; +PSI_stage_info stage_commit= { 0, "Commit", 0}; +PSI_stage_info stage_commit_implicit= { 0, "Commit_implicit", 0}; PSI_stage_info stage_queueing_master_event_to_the_relay_log= { 0, "Queueing master event to the relay log", 0}; PSI_stage_info stage_reading_event_from_the_relay_log= { 0, "Reading event from the relay log", 0}; -PSI_stage_info stage_recreating_table= { 0, "recreating table", 0}; +PSI_stage_info stage_recreating_table= { 0, "Recreating table", 0}; PSI_stage_info stage_registering_slave_on_master= { 0, "Registering slave on master", 0}; PSI_stage_info stage_removing_duplicates= { 0, "Removing duplicates", 0}; -PSI_stage_info stage_removing_tmp_table= { 0, "removing tmp table", 0}; -PSI_stage_info stage_rename= { 0, "rename", 0}; -PSI_stage_info stage_rename_result_table= { 0, "rename result table", 0}; +PSI_stage_info stage_removing_tmp_table= { 0, "Removing tmp table", 0}; +PSI_stage_info stage_rename= { 0, "Rename", 0}; +PSI_stage_info stage_rename_result_table= { 0, "Rename result table", 0}; PSI_stage_info stage_requesting_binlog_dump= { 0, "Requesting binlog dump", 0}; -PSI_stage_info stage_reschedule= { 0, "reschedule", 0}; +PSI_stage_info stage_reschedule= { 0, "Reschedule", 0}; PSI_stage_info stage_searching_rows_for_update= { 0, "Searching rows for update", 0}; PSI_stage_info stage_sending_binlog_event_to_slave= { 0, "Sending binlog event to slave", 0}; -PSI_stage_info stage_sending_cached_result_to_client= { 0, "sending cached result to client", 0}; +PSI_stage_info stage_sending_cached_result_to_client= { 0, "Sending cached result to client", 0}; PSI_stage_info stage_sending_data= { 0, "Sending data", 0}; -PSI_stage_info stage_setup= { 0, "setup", 0}; -PSI_stage_info stage_show_explain= { 0, "show explain", 0}; +PSI_stage_info stage_setup= { 0, "Setup", 0}; +PSI_stage_info stage_show_explain= { 0, "Show explain", 0}; PSI_stage_info stage_slave_has_read_all_relay_log= { 0, "Slave has read all relay log; waiting for the slave I/O thread to update it", 0}; PSI_stage_info stage_sorting= { 0, "Sorting", 0}; PSI_stage_info stage_sorting_for_group= { 0, "Sorting for group", 0}; PSI_stage_info stage_sorting_for_order= { 0, "Sorting for order", 0}; PSI_stage_info stage_sorting_result= { 0, "Sorting result", 0}; -PSI_stage_info stage_statistics= { 0, "statistics", 0}; +PSI_stage_info stage_statistics= { 0, "Statistics", 0}; PSI_stage_info stage_sql_thd_waiting_until_delay= { 0, "Waiting until MASTER_DELAY seconds after master executed event", 0 }; -PSI_stage_info stage_storing_result_in_query_cache= { 0, "storing result in query cache", 0}; -PSI_stage_info stage_storing_row_into_queue= { 0, "storing row into queue", 0}; +PSI_stage_info stage_storing_result_in_query_cache= { 0, "Storing result in query cache", 0}; +PSI_stage_info stage_storing_row_into_queue= { 0, "Storing row into queue", 0}; PSI_stage_info stage_system_lock= { 0, "System lock", 0}; PSI_stage_info stage_unlocking_tables= { 0, "Unlocking tables", 0}; PSI_stage_info stage_table_lock= { 0, "Table lock", 0}; PSI_stage_info stage_filling_schema_table= { 0, "Filling schema table", 0}; -PSI_stage_info stage_update= { 0, "update", 0}; -PSI_stage_info stage_updating= { 0, "updating", 0}; -PSI_stage_info stage_updating_main_table= { 0, "updating main table", 0}; -PSI_stage_info stage_updating_reference_tables= { 0, "updating reference tables", 0}; -PSI_stage_info stage_upgrading_lock= { 0, "upgrading lock", 0}; +PSI_stage_info stage_update= { 0, "Update", 0}; +PSI_stage_info stage_updating= { 0, "Updating", 0}; +PSI_stage_info stage_updating_main_table= { 0, "Updating main table", 0}; +PSI_stage_info stage_updating_reference_tables= { 0, "Updating reference tables", 0}; +PSI_stage_info stage_upgrading_lock= { 0, "Upgrading lock", 0}; PSI_stage_info stage_user_lock= { 0, "User lock", 0}; PSI_stage_info stage_user_sleep= { 0, "User sleep", 0}; -PSI_stage_info stage_verifying_table= { 0, "verifying table", 0}; -PSI_stage_info stage_waiting_for_delay_list= { 0, "waiting for delay_list", 0}; -PSI_stage_info stage_waiting_for_gtid_to_be_written_to_binary_log= { 0, "waiting for GTID to be written to binary log", 0}; -PSI_stage_info stage_waiting_for_handler_insert= { 0, "waiting for handler insert", 0}; -PSI_stage_info stage_waiting_for_handler_lock= { 0, "waiting for handler lock", 0}; -PSI_stage_info stage_waiting_for_handler_open= { 0, "waiting for handler open", 0}; +PSI_stage_info stage_verifying_table= { 0, "Verifying table", 0}; +PSI_stage_info stage_waiting_for_delay_list= { 0, "Waiting for delay_list", 0}; +PSI_stage_info stage_waiting_for_gtid_to_be_written_to_binary_log= { 0, "Waiting for GTID to be written to binary log", 0}; +PSI_stage_info stage_waiting_for_handler_insert= { 0, "Waiting for handler insert", 0}; +PSI_stage_info stage_waiting_for_handler_lock= { 0, "Waiting for handler lock", 0}; +PSI_stage_info stage_waiting_for_handler_open= { 0, "Waiting for handler open", 0}; PSI_stage_info stage_waiting_for_insert= { 0, "Waiting for INSERT", 0}; PSI_stage_info stage_waiting_for_master_to_send_event= { 0, "Waiting for master to send event", 0}; PSI_stage_info stage_waiting_for_master_update= { 0, "Waiting for master update", 0}; PSI_stage_info stage_waiting_for_relay_log_space= { 0, "Waiting for the slave SQL thread to free enough relay log space", 0}; +PSI_stage_info stage_waiting_for_semi_sync_ack_from_slave= +{ 0, "Waiting for semi-sync ACK from slave", 0}; +PSI_stage_info stage_waiting_for_semi_sync_slave={ 0, "Waiting for semi-sync slave connection", 0}; +PSI_stage_info stage_reading_semi_sync_ack={ 0, "Reading semi-sync ACK from slave", 0}; PSI_stage_info stage_waiting_for_slave_mutex_on_exit= { 0, "Waiting for slave mutex on exit", 0}; PSI_stage_info stage_waiting_for_slave_thread_to_start= { 0, "Waiting for slave thread to start", 0}; PSI_stage_info stage_waiting_for_table_flush= { 0, "Waiting for table flush", 0}; @@ -10215,6 +10380,7 @@ PSI_stage_info stage_waiting_for_the_slave_thread_to_advance_position= { 0, "Wai PSI_stage_info stage_waiting_to_finalize_termination= { 0, "Waiting to finalize termination", 0}; PSI_stage_info stage_waiting_to_get_readlock= { 0, "Waiting to get readlock", 0}; PSI_stage_info stage_binlog_waiting_background_tasks= { 0, "Waiting for background binlog tasks", 0}; +PSI_stage_info stage_binlog_write= { 0, "Writing to binlog", 0}; PSI_stage_info stage_binlog_processing_checkpoint_notify= { 0, "Processing binlog checkpoint notification", 0}; PSI_stage_info stage_binlog_stopping_background_thread= { 0, "Stopping binlog background thread", 0}; PSI_stage_info stage_waiting_for_work_from_sql_thread= { 0, "Waiting for work from SQL thread", 0}; @@ -10245,6 +10411,7 @@ PSI_stage_info *all_server_stages[]= & stage_alter_inplace_commit, & stage_alter_inplace_prepare, & stage_apply_event, + & stage_binlog_write, & stage_binlog_processing_checkpoint_notify, & stage_binlog_stopping_background_thread, & stage_binlog_waiting_background_tasks, @@ -10255,6 +10422,8 @@ PSI_stage_info *all_server_stages[]= & stage_checking_query_cache_for_query, & stage_cleaning_up, & stage_closing_tables, + & stage_commit, + & stage_commit_implicit, & stage_connecting_to_master, & stage_converting_heap_to_myisam, & stage_copy_to_tmp_table, @@ -10281,6 +10450,7 @@ PSI_stage_info *all_server_stages[]= & stage_got_handler_lock, & stage_got_old_table, & stage_init, + & stage_init_update, & stage_insert, & stage_invalidating_query_cache_entries_table, & stage_invalidating_query_cache_entries_table_list, @@ -10294,6 +10464,7 @@ PSI_stage_info *all_server_stages[]= & stage_optimizing, & stage_preparing, & stage_purging_old_relay_logs, + & stage_starting_cleanup, & stage_query_end, & stage_queueing_master_event_to_the_relay_log, & stage_reading_event_from_the_relay_log, @@ -10305,6 +10476,8 @@ PSI_stage_info *all_server_stages[]= & stage_rename_result_table, & stage_requesting_binlog_dump, & stage_reschedule, + & stage_rollback, + & stage_rollback_implicit, & stage_searching_rows_for_update, & stage_sending_binlog_event_to_slave, & stage_sending_cached_result_to_client, @@ -10358,6 +10531,9 @@ PSI_stage_info *all_server_stages[]= & stage_gtid_wait_other_connection, & stage_slave_background_process_request, & stage_slave_background_wait_request, + & stage_waiting_for_semi_sync_ack_from_slave, + & stage_waiting_for_semi_sync_slave, + & stage_reading_semi_sync_ack, & stage_waiting_for_deadlock_kill }; |