From 02e897ca57168059c6a74d1129158afea93aa875 Mon Sep 17 00:00:00 2001 From: Andrei Elkin Date: Mon, 16 Apr 2018 20:34:55 +0300 Subject: MDEV-15889 Semisync ack thread hits an LOCK_plugin assert at shutdown MDEV-13073 effectively made the master semisync component depending on the plugin one through instantiation of THD by its Ack thread. The thread therefore must be closing its resources prior to plugin_shutdown(), which was not the case. Fixed with implementing the requirement. --- sql/mysqld.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sql/mysqld.cc') diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 2db3bbe1bac..6e1a5997e15 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2240,14 +2240,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(); -#ifdef HAVE_REPLICATION - semi_sync_master_deinit(); -#endif xid_cache_free(); tdc_deinit(); mdl_destroy(); -- cgit v1.2.1 From 2ccd6716fc730b3ff5e1bc2f8dc08ac561db3cb4 Mon Sep 17 00:00:00 2001 From: Monty Date: Thu, 26 Apr 2018 16:33:05 +0300 Subject: Fix a lot of compiler warnings found by -Wunused --- sql/mysqld.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql/mysqld.cc') diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 6e1a5997e15..851082a98e4 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -8998,7 +8998,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; -- cgit v1.2.1 From cd48c1e23a0ca203d87786ae9b0f53aff4c1b433 Mon Sep 17 00:00:00 2001 From: Monty Date: Thu, 26 Apr 2018 17:57:38 +0300 Subject: Removed some old #if MYSQL_VERSION - Removed never used warning that explicit_defaults_for_timestamp was not set --- sql/mysqld.cc | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'sql/mysqld.cc') diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 851082a98e4..2b1b09c7e59 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -9680,17 +9680,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 -- cgit v1.2.1 From 6e42d19f2599b12ac3ff5a82fdcd59e2c261f98c Mon Sep 17 00:00:00 2001 From: Alexey Botchkov Date: Thu, 26 Apr 2018 23:12:51 +0400 Subject: MDEV-15915 Add Feature_json status variable. Related implementations. --- 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 2b1b09c7e59..286a73d55de 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -8553,6 +8553,7 @@ SHOW_VAR status_vars[]= { {"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_timezone", (char*) offsetof(STATUS_VAR, feature_timezone), SHOW_LONG_STATUS}, -- cgit v1.2.1 From 30ebc3ee9efcab635b1f3e14b9198a58ae93c233 Mon Sep 17 00:00:00 2001 From: Monty Date: Wed, 4 Apr 2018 12:16:12 +0300 Subject: Add likely/unlikely to speed up execution Added to: - if (error) - Lex - sql_yacc.yy and sql_yacc_ora.yy - In header files to alloc() calls - Added thd argument to thd_net_is_killed() --- sql/mysqld.cc | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) (limited to 'sql/mysqld.cc') diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 286a73d55de..97b2299defc 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1957,10 +1957,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; @@ -2569,7 +2570,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)); @@ -3472,8 +3473,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); @@ -3575,10 +3577,10 @@ pthread_handler_t signal_hand(void *arg __attribute__((unused))) 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 @@ -3670,9 +3672,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); } @@ -3682,7 +3684,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; } @@ -4088,7 +4090,7 @@ static void my_malloc_size_cb_func(long long size, my_bool is_thread_specific) 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; @@ -5364,7 +5366,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 @@ -5551,7 +5553,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); } @@ -5585,7 +5587,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); @@ -5617,9 +5619,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); @@ -9551,7 +9553,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; -- cgit v1.2.1 From 735203e6de5c6db5fb7fcd09f908ce45ee992d7d Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 2 May 2018 15:45:51 +0200 Subject: cleanup: quoted_string --- sql/mysqld.cc | 1 - 1 file changed, 1 deletion(-) (limited to 'sql/mysqld.cc') diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 97b2299defc..af817894cf4 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -304,7 +304,6 @@ static TYPELIB tc_heuristic_recover_typelib= const char *first_keyword= "first"; const char *my_localhost= "localhost", *delayed_user= "DELAYED"; -const char *quoted_string= "%`s"; bool opt_large_files= sizeof(my_off_t) > 4; static my_bool opt_autocommit; ///< for --autocommit command-line option -- cgit v1.2.1 From 4203f572aeebb55ad97c9576d58c0a14ed73862a Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 2 May 2018 17:55:00 +0200 Subject: MDEV-15923 option to control who can set session @@timestamp --secure-timestamp=NO|SUPER|REPLICATION|YES --- 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 af817894cf4..28b5d3bd0ad 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -534,6 +534,7 @@ 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 -- cgit v1.2.1 From fddaaf729521ebafd0469adf3f9e36dcc079a26f Mon Sep 17 00:00:00 2001 From: Aleksey Midenkov Date: Sat, 28 Apr 2018 20:40:34 +0300 Subject: MDEV-15978 Add Feature_system_versioning status variable --- 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 28b5d3bd0ad..dd79cb39f80 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -8558,6 +8558,7 @@ SHOW_VAR status_vars[]= { {"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}, -- cgit v1.2.1 From 7a4f81b4c0d78e51c7b260b6f84e2732fbb99192 Mon Sep 17 00:00:00 2001 From: Monty Date: Thu, 24 May 2018 16:20:31 +0300 Subject: Extend debug_assert_on_not_freed_memory Don't check global_memory_used if debug_assert_on_not_freed_memory is not set --- sql/mysqld.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sql/mysqld.cc') diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 99cad2c0423..8dd178108b9 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2169,7 +2169,8 @@ static void mysqld_exit(int exit_code) if (opt_endinfo && global_status_var.global_memory_used) fprintf(stderr, "Warning: Memory not freed: %ld\n", (long) global_status_var.global_memory_used); - if (!opt_debugging && !my_disable_leak_check && exit_code == 0) + 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); } -- cgit v1.2.1