From 416b7144d50304a428938bb23848f2db8331824d Mon Sep 17 00:00:00 2001 From: Mikael Ronstrom Date: Mon, 24 Jan 2011 14:57:07 +0100 Subject: BUG#59549, Fix compiler errors on Windows, step 5 --- sql/mysqld.cc | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'sql/mysqld.cc') diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 188ed7c6885..15588cadaae 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -450,7 +450,7 @@ uint lower_case_table_names; ulong tc_heuristic_recover= 0; uint volatile thread_count; int32 thread_running; -ulong thread_created; +MYSQL_PLUGIN_IMPORT ulong thread_created; ulong back_log, connect_timeout, concurrency, server_id; ulong table_cache_size, table_def_size; ulong what_to_log; @@ -477,7 +477,8 @@ ulong delayed_insert_errors,flush_time; ulong specialflag=0; ulong binlog_cache_use= 0, binlog_cache_disk_use= 0; ulong binlog_stmt_cache_use= 0, binlog_stmt_cache_disk_use= 0; -ulong max_connections, max_connect_errors; +MYSQL_PLUGIN_IMPORT ulong max_connections; +ulong max_connect_errors; /** Limit of the total number of prepared statements in the server. Is necessary to protect the server against out-of-memory attacks. @@ -580,7 +581,7 @@ Le_creator le_creator; MYSQL_FILE *bootstrap_file; int bootstrap_error; -I_List threads; +MYSQL_PLUGIN_IMPORT I_List threads; Rpl_filter* rpl_filter; Rpl_filter* binlog_filter; @@ -629,9 +630,9 @@ mysql_mutex_t LOCK_des_key_file; #endif mysql_rwlock_t LOCK_grant, LOCK_sys_init_connect, LOCK_sys_init_slave; mysql_rwlock_t LOCK_system_variables_hash; -mysql_cond_t COND_thread_count; +MYSQL_PLUGIN_IMPORT mysql_cond_t COND_thread_count; pthread_t signal_thread; -pthread_attr_t connection_attrib; +MYSQL_PLUGIN_IMPORT pthread_attr_t connection_attrib; mysql_mutex_t LOCK_server_started; mysql_cond_t COND_server_started; @@ -7792,7 +7793,9 @@ static PSI_cond_info all_server_conds[]= 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_signal_hand; + +MYSQL_PLUGIN_IMPORT PSI_thread_key key_thread_one_connection; static PSI_thread_info all_server_threads[]= { -- cgit v1.2.1 From fbbe9c2e8ee268222348adb1173cf5fdbcc694d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikael=20Ronstr=C3=B6m?= Date: Thu, 3 Feb 2011 21:05:34 +0100 Subject: Fixed such that debug_sync can be used by plugins on Windows --- 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 15588cadaae..02e8d8de42f 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -425,7 +425,7 @@ my_bool opt_super_large_pages= 0; my_bool opt_myisam_use_mmap= 0; uint opt_large_page_size= 0; #if defined(ENABLED_DEBUG_SYNC) -uint opt_debug_sync_timeout= 0; +MYSQL_PLUGIN_IMPORT uint opt_debug_sync_timeout= 0; #endif /* defined(ENABLED_DEBUG_SYNC) */ my_bool opt_old_style_user_limits= 0, trust_function_creators= 0; /* -- cgit v1.2.1 From 715d404eea606741cf09946492989b7362108583 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikael=20Ronstr=C3=B6m?= Date: Wed, 16 Feb 2011 20:38:35 +0100 Subject: More work on interfaces --- sql/mysqld.cc | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'sql/mysqld.cc') diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 38dc3d6557e..8f5fed07948 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -4895,6 +4895,14 @@ static bool read_init_file(char *file_name) } +/** + Increment number of created threads +*/ +void inc_thread_created(void) +{ + thread_created++; +} + #ifndef EMBEDDED_LIBRARY /* -- cgit v1.2.1 From e2602f4eab51adc75bfa44f853ccc14c21130be7 Mon Sep 17 00:00:00 2001 From: Mikael Ronstrom Date: Fri, 13 May 2011 15:46:35 +0200 Subject: Removed variables no longer needed in plugins, moved to methods instead --- sql/mysqld.cc | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'sql/mysqld.cc') diff --git a/sql/mysqld.cc b/sql/mysqld.cc index f078c703a1a..6776f04758f 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -447,7 +447,7 @@ uint lower_case_table_names; ulong tc_heuristic_recover= 0; uint volatile thread_count; int32 thread_running; -MYSQL_PLUGIN_IMPORT ulong thread_created; +ulong thread_created; ulong back_log, connect_timeout, concurrency, server_id; ulong table_cache_size, table_def_size; ulong what_to_log; @@ -474,8 +474,7 @@ ulong delayed_insert_errors,flush_time; ulong specialflag=0; ulong binlog_cache_use= 0, binlog_cache_disk_use= 0; ulong binlog_stmt_cache_use= 0, binlog_stmt_cache_disk_use= 0; -MYSQL_PLUGIN_IMPORT ulong max_connections; -ulong max_connect_errors; +ulong max_connections, max_connect_errors; /* Maximum length of parameter value which can be set through mysql_send_long_data() call. @@ -583,7 +582,7 @@ Le_creator le_creator; MYSQL_FILE *bootstrap_file; int bootstrap_error; -MYSQL_PLUGIN_IMPORT I_List threads; +I_List threads; Rpl_filter* rpl_filter; Rpl_filter* binlog_filter; @@ -632,9 +631,9 @@ mysql_mutex_t LOCK_des_key_file; #endif mysql_rwlock_t LOCK_grant, LOCK_sys_init_connect, LOCK_sys_init_slave; mysql_rwlock_t LOCK_system_variables_hash; -MYSQL_PLUGIN_IMPORT mysql_cond_t COND_thread_count; +mysql_cond_t COND_thread_count; pthread_t signal_thread; -MYSQL_PLUGIN_IMPORT pthread_attr_t connection_attrib; +pthread_attr_t connection_attrib; mysql_mutex_t LOCK_server_started; mysql_cond_t COND_server_started; @@ -7871,9 +7870,7 @@ static PSI_cond_info all_server_conds[]= PSI_thread_key key_thread_bootstrap, key_thread_delayed_insert, key_thread_handle_manager, key_thread_main, - key_thread_signal_hand; - -MYSQL_PLUGIN_IMPORT PSI_thread_key key_thread_one_connection; + key_thread_one_connection, key_thread_signal_hand; static PSI_thread_info all_server_threads[]= { -- cgit v1.2.1 From 89ec54264d095799f3247687d21dc5c6e02242de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikael=20Ronstr=C3=B6m?= Date: Wed, 18 May 2011 09:38:05 +0200 Subject: Split up unlink_thd in several functions --- sql/mysqld.cc | 39 ++++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) (limited to 'sql/mysqld.cc') diff --git a/sql/mysqld.cc b/sql/mysqld.cc index f078c703a1a..2192b0f3ee9 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2009,6 +2009,36 @@ extern "C" sig_handler end_thread_signal(int sig __attribute__((unused))) } +/* + Decrease number of connections + + SYNOPSIS + dec_connection_count() +*/ + +void dec_connection_count() +{ + mysql_mutex_lock(&LOCK_connection_count); + --connection_count; + mysql_mutex_unlock(&LOCK_connection_count); +} + + +/* + Delete the THD object and decrease number of threads + + SYNOPSIS + delete_thd() + thd Thread handler +*/ + +void delete_thd(THD *thd) +{ + thread_count--; + delete thd; +} + + /* Unlink thd from global list of available connections and free thd @@ -2024,15 +2054,10 @@ void unlink_thd(THD *thd) { DBUG_ENTER("unlink_thd"); DBUG_PRINT("enter", ("thd: 0x%lx", (long) thd)); - thd->cleanup(); - - mysql_mutex_lock(&LOCK_connection_count); - --connection_count; - mysql_mutex_unlock(&LOCK_connection_count); + dec_connection_count(); mysql_mutex_lock(&LOCK_thread_count); - thread_count--; - delete thd; + delete_thd(thd); DBUG_VOID_RETURN; } -- cgit v1.2.1 From f125f2994fe65bd40e42e4809b4b284cbe8017d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikael=20Ronstr=C3=B6m?= Date: Wed, 25 May 2011 12:17:27 +0200 Subject: BUG#12578441, reintroduced thd->cleanup() in unlink_thd, removed by mistake, added private interface to this function --- sql/mysqld.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'sql/mysqld.cc') diff --git a/sql/mysqld.cc b/sql/mysqld.cc index d67a04bcc23..8ea076e72ba 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2008,6 +2008,19 @@ extern "C" sig_handler end_thread_signal(int sig __attribute__((unused))) } +/* + Cleanup THD object + + SYNOPSIS + thd_cleanup() + thd Thread handler +*/ + +void thd_cleanup(THD *thd) +{ + thd->cleanup(); +} + /* Decrease number of connections @@ -2054,6 +2067,7 @@ void unlink_thd(THD *thd) DBUG_ENTER("unlink_thd"); DBUG_PRINT("enter", ("thd: 0x%lx", (long) thd)); + thd_cleanup(thd); dec_connection_count(); mysql_mutex_lock(&LOCK_thread_count); delete_thd(thd); -- cgit v1.2.1 From de3776819c2163a8974af7e4e77e5a648e72f5ab Mon Sep 17 00:00:00 2001 From: Sven Sandberg Date: Thu, 26 May 2011 12:50:43 +0200 Subject: BUG#12574820: binlog.binlog_tmp_table timing out in daily and weekly trunk run Problem: MYSQL_BIN_LOG::reset_logs acquires mutexes in wrong order. The correct order is first LOCK_thread_count and then LOCK_log. This function does it the other way around. This leads to deadlock when run in parallel with a thread that takes the two locks in correct order. For example, a thread that disconnects will take the locks in the correct order. Fix: change order of the locks in MYSQL_BIN_LOG::reset_logs: first LOCK_thread_count and then LOCK_log. mysql-test/suite/binlog/r/binlog_reset_master.result: added result file mysql-test/suite/binlog/t/binlog_reset_master.test: Added test case that demonstrates deadlock because of wrong mutex order. The deadlock is between two threads: - RESET MASTER acquires mutexes in wrong order. - client thread shutdown code acquires mutexes in right order. Actually, this test case does not produce deadlock in 5.1, probably the client thread shutdown code does not hold both mutexes at the same time. However, the bug existed in 5.1 (mutexes are taken in the wrong order) so we push the test case to 5.1 too, to prevent future regressions. sql/log.cc: Change mutex acquisition to the correct order: first LOCK_thread_count, then LOCK_log. sql/mysqld.cc: Add debug code to synchronize test case. --- sql/mysqld.cc | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'sql/mysqld.cc') diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 54850f36d10..2d1290bf88a 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1903,6 +1903,12 @@ void unlink_thd(THD *thd) pthread_mutex_unlock(&LOCK_connection_count); (void) pthread_mutex_lock(&LOCK_thread_count); + /* + Used by binlog_reset_master. It would be cleaner to use + DEBUG_SYNC here, but that's not possible because the THD's debug + sync feature has been shut down at this point. + */ + DBUG_EXECUTE_IF("sleep_after_lock_thread_count_before_delete_thd", sleep(5);); thread_count--; delete thd; DBUG_VOID_RETURN; -- cgit v1.2.1 From b502a64bba3143a77632042f02876086ab7dff7b Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Mon, 6 Jun 2011 13:13:54 +0300 Subject: Bug #11749418: 38965: TEST CASES GIS-RTREE, TYPE_FLOAT, TYPE_NEWDECIMAL FAIL IN EMBEDDED SERVER FreeBSD 64 bit needs the FP_X_DNML to fpsetmask() to prevent exceptions from propagating into mysql (as a threaded application). However fpsetmask() itself is deprecated in favor of fedisableexcept(). 1. Fixed the #ifdef to check for FP_X_DNML instead of i386. 2. Added a configure.in check for fedisableexcept() and, if present, this function is called insted of the fpsetmask(). No need for new tests, as the existing tests cover this already. Removed the affected tests from the experimental list. --- sql/mysqld.cc | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'sql/mysqld.cc') diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 2d1290bf88a..36f195e6232 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -171,12 +171,12 @@ static void getvolumeID(BYTE *volumeName); int initgroups(const char *,unsigned int); #endif -#if defined(__FreeBSD__) && defined(HAVE_IEEEFP_H) +#if defined(__FreeBSD__) && defined(HAVE_IEEEFP_H) && !defined(HAVE_FEDISABLEEXCEPT) #include #ifdef HAVE_FP_EXCEPT // Fix type conflict typedef fp_except fp_except_t; #endif -#endif /* __FreeBSD__ && HAVE_IEEEFP_H */ +#endif /* __FreeBSD__ && HAVE_IEEEFP_H && !HAVE_FEDISABLEEXCEPT */ #ifdef HAVE_SYS_FPU_H /* for IRIX to use set_fpc_csr() */ #include @@ -202,19 +202,24 @@ extern "C" my_bool reopen_fstreams(const char *filename, inline void setup_fpu() { -#if defined(__FreeBSD__) && defined(HAVE_IEEEFP_H) +#if defined(__FreeBSD__) && defined(HAVE_IEEEFP_H) && !defined(HAVE_FEDISABLEEXCEPT) /* We can't handle floating point exceptions with threads, so disable this on freebsd - Don't fall for overflow, underflow,divide-by-zero or loss of precision + Don't fall for overflow, underflow,divide-by-zero or loss of precision. + fpsetmask() is deprecated in favor of fedisableexcept() in C99. */ -#if defined(__i386__) +#if defined(FP_X_DNML) fpsetmask(~(FP_X_INV | FP_X_DNML | FP_X_OFL | FP_X_UFL | FP_X_DZ | FP_X_IMP)); #else fpsetmask(~(FP_X_INV | FP_X_OFL | FP_X_UFL | FP_X_DZ | FP_X_IMP)); -#endif /* __i386__ */ -#endif /* __FreeBSD__ && HAVE_IEEEFP_H */ +#endif /* FP_X_DNML */ +#endif /* __FreeBSD__ && HAVE_IEEEFP_H && !HAVE_FEDISABLEEXCEPT */ + +#ifdef HAVE_FEDISABLEEXCEPT + fedisableexcept(FE_ALL_EXCEPT); +#endif #ifdef HAVE_FESETROUND /* Set FPU rounding mode to "round-to-nearest" */ -- cgit v1.2.1