diff options
author | Seppo Jaakola <seppo.jaakola@codership.com> | 2012-08-09 01:47:21 +0300 |
---|---|---|
committer | Seppo Jaakola <seppo.jaakola@codership.com> | 2012-08-09 01:47:21 +0300 |
commit | ebfa24b1d24377a241b79883da96969a9150f22c (patch) | |
tree | ef1198f9dfb1838cbdbc5056f2b84e399b446bfd /sql/mysqld.cc | |
parent | 1fd2e10736d6fd198e62054cb9006a3dc13fd55e (diff) | |
parent | a7123f507598690ef0fce68b5d8dc58e63635024 (diff) | |
download | mariadb-git-ebfa24b1d24377a241b79883da96969a9150f22c.tar.gz |
References lp:1034621 - Merge up to mysql-5.5.25 level
merged codership-mysql/5.5 revisions: bzr diff -r3759..3767
merged codership-mysql/5.5 revisions: bzr diff -r3768..3771
Diffstat (limited to 'sql/mysqld.cc')
-rw-r--r-- | sql/mysqld.cc | 63 |
1 files changed, 47 insertions, 16 deletions
diff --git a/sql/mysqld.cc b/sql/mysqld.cc index eaaff295ae0..dfdf1c41c0f 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -110,7 +110,7 @@ ulong wsrep_running_threads = 0; // # of currently running wsrep threads /* We have HAVE_valgrind below as this speeds up the shutdown of MySQL */ -#if defined(HAVE_DEC_3_2_THREADS) || defined(SIGNALS_DONT_BREAK_READ) || defined(HAVE_valgrind) && defined(__linux__) +#if defined(SIGNALS_DONT_BREAK_READ) || defined(HAVE_valgrind) && defined(__linux__) #define HAVE_CLOSE_SERVER_SOCK 1 #endif @@ -694,6 +694,7 @@ mysql_cond_t COND_wsrep_rollback; wsrep_aborting_thd_t wsrep_aborting_thd= NULL; mysql_mutex_t LOCK_wsrep_replaying; mysql_cond_t COND_wsrep_replaying; +mysql_mutex_t LOCK_wsrep_slave_threads; int wsrep_replaying= 0; static void wsrep_close_threads(THD* thd); #endif @@ -768,7 +769,8 @@ PSI_mutex_key key_BINLOG_LOCK_index, key_BINLOG_LOCK_prep_xids, #ifdef WITH_WSREP PSI_mutex_key key_LOCK_wsrep_rollback, key_LOCK_wsrep_thd, key_LOCK_wsrep_replaying, key_LOCK_wsrep_ready, key_LOCK_wsrep_sst, - key_LOCK_wsrep_sst_thread, key_LOCK_wsrep_sst_init; + key_LOCK_wsrep_sst_thread, key_LOCK_wsrep_sst_init, + key_LOCK_wsrep_slave_threads; #endif PSI_mutex_key key_RELAYLOG_LOCK_index; @@ -846,6 +848,7 @@ static PSI_mutex_info all_server_mutexes[]= { &key_LOCK_wsrep_rollback, "LOCK_wsrep_rollback", PSI_FLAG_GLOBAL}, { &key_LOCK_wsrep_thd, "THD::LOCK_wsrep_thd", 0}, { &key_LOCK_wsrep_replaying, "LOCK_wsrep_replaying", PSI_FLAG_GLOBAL}, + { &key_LOCK_wsrep_slave_threads, "LOCK_wsrep_slave_threads", PSI_FLAG_GLOBAL}, #endif { &key_PARTITION_LOCK_auto_inc, "HA_DATA_PARTITION::LOCK_auto_inc", 0} }; @@ -2047,6 +2050,7 @@ static void clean_up_mutexes() (void) mysql_cond_destroy(&COND_wsrep_rollback); (void) mysql_mutex_destroy(&LOCK_wsrep_replaying); (void) mysql_cond_destroy(&COND_wsrep_replaying); + (void) mysql_mutex_destroy(&LOCK_wsrep_slave_threads); #endif mysql_mutex_destroy(&LOCK_server_started); mysql_cond_destroy(&COND_server_started); @@ -3051,11 +3055,9 @@ static void start_signal_handler(void) DBUG_ENTER("start_signal_handler"); (void) pthread_attr_init(&thr_attr); -#if !defined(HAVE_DEC_3_2_THREADS) pthread_attr_setscope(&thr_attr,PTHREAD_SCOPE_SYSTEM); (void) pthread_attr_setdetachstate(&thr_attr,PTHREAD_CREATE_DETACHED); (void) my_setstacksize(&thr_attr,my_thread_stack_size); -#endif mysql_mutex_lock(&LOCK_thread_count); if ((error= mysql_thread_create(key_thread_signal_hand, @@ -3542,14 +3544,23 @@ static int init_common_variables() return 1; #ifdef HAVE_TZNAME - { - struct tm tm_tmp; - localtime_r(&server_start_time,&tm_tmp); - strmake(system_time_zone, tzname[tm_tmp.tm_isdst != 0 ? 1 : 0], - sizeof(system_time_zone)-1); + struct tm tm_tmp; + localtime_r(&server_start_time,&tm_tmp); + const char *tz_name= tzname[tm_tmp.tm_isdst != 0 ? 1 : 0]; +#ifdef _WIN32 + /* + Time zone name may be localized and contain non-ASCII characters, + Convert from ANSI encoding to UTF8. + */ + wchar_t wtz_name[sizeof(system_time_zone)]; + mbstowcs(wtz_name, tz_name, sizeof(system_time_zone)-1); + WideCharToMultiByte(CP_UTF8,0, wtz_name, -1, system_time_zone, + sizeof(system_time_zone) - 1, NULL, NULL); +#else + strmake(system_time_zone, tz_name, sizeof(system_time_zone)-1); +#endif /* _WIN32 */ +#endif /* HAVE_TZNAME */ - } -#endif /* We set SYSTEM time zone as reasonable default and also for failure of my_tz_init() and bootstrap mode. @@ -4065,6 +4076,8 @@ static int init_thread_environment() mysql_mutex_init(key_LOCK_wsrep_replaying, &LOCK_wsrep_replaying, MY_MUTEX_INIT_FAST); mysql_cond_init(key_COND_wsrep_replaying, &COND_wsrep_replaying, NULL); + mysql_mutex_init(key_LOCK_wsrep_slave_threads, + &LOCK_wsrep_slave_threads, MY_MUTEX_INIT_FAST); #endif return 0; } @@ -5002,9 +5015,7 @@ void wsrep_close_client_connections(my_bool wait_to_end) void wsrep_close_applier(THD *thd) { - if (wsrep_debug) - WSREP_INFO("closing applier %ld", thd->thread_id); - + WSREP_DEBUG("closing applier %ld", thd->thread_id); wsrep_close_thread(thd); } @@ -5021,10 +5032,30 @@ static void wsrep_close_threads(THD *thd) /* We skip slave threads & scheduler on this first loop through. */ if (tmp->wsrep_applier && tmp != thd) { - if (wsrep_debug) - WSREP_INFO("closing wsrep thread %ld", tmp->thread_id); + WSREP_DEBUG("closing wsrep thread %ld", tmp->thread_id); wsrep_close_thread (tmp); + } + } + mysql_mutex_unlock(&LOCK_thread_count); +} + +void wsrep_close_applier_threads(int count) +{ + THD *tmp; + mysql_mutex_lock(&LOCK_thread_count); // For unlink from list + + I_List_iterator<THD> it(threads); + while ((tmp=it++) && count) + { + DBUG_PRINT("quit",("Informing thread %ld that it's time to die", + tmp->thread_id)); + /* We skip slave threads & scheduler on this first loop through. */ + if (tmp->wsrep_applier) + { + WSREP_DEBUG("closing wsrep applier thread %ld", tmp->thread_id); + tmp->wsrep_applier_closing= TRUE; + count--; } } |