Commit 1cc38f83 authored by tomas@whalegate.ndb.mysql.com's avatar tomas@whalegate.ndb.mysql.com

Merge tulin@bk-internal.mysql.com:/home/bk/mysql-5.1-build

into  whalegate.ndb.mysql.com:/home/tomas/mysql-5.1-build
parents 3365b2a4 0c66cf7b
...@@ -29,25 +29,6 @@ extern "C" { ...@@ -29,25 +29,6 @@ extern "C" {
#define EXTERNC #define EXTERNC
#endif /* __cplusplus */ #endif /* __cplusplus */
/*
BUG#24507: Race conditions inside current NPTL pthread_exit() implementation.
If macro NPTL_PTHREAD_EXIT_HACK is defined then a hack described in the bug
report will be implemented inside my_thread_global_init() in my_thr_init.c.
This amounts to spawning a dummy thread which does nothing but executes
pthread_exit(0).
This bug is fixed in version 2.5 of glibc library.
TODO: Remove this code when fixed versions of glibc6 are in common use.
*/
#if defined(TARGET_OS_LINUX) && defined(HAVE_NPTL) && \
defined(__GLIBC__) && ( __GLIBC__ < 2 || __GLIBC__ == 2 && __GLIBC_MINOR__ < 5 )
#define NPTL_PTHREAD_EXIT_BUG 1
#endif
#if defined(__WIN__) #if defined(__WIN__)
typedef CRITICAL_SECTION pthread_mutex_t; typedef CRITICAL_SECTION pthread_mutex_t;
typedef HANDLE pthread_t; typedef HANDLE pthread_t;
...@@ -179,7 +160,7 @@ void pthread_exit(void *a); /* was #define pthread_exit(A) ExitThread(A)*/ ...@@ -179,7 +160,7 @@ void pthread_exit(void *a); /* was #define pthread_exit(A) ExitThread(A)*/
#define pthread_mutex_unlock(A) LeaveCriticalSection(A) #define pthread_mutex_unlock(A) LeaveCriticalSection(A)
#define pthread_mutex_destroy(A) DeleteCriticalSection(A) #define pthread_mutex_destroy(A) DeleteCriticalSection(A)
#define my_pthread_setprio(A,B) SetThreadPriority(GetCurrentThread(), (B)) #define my_pthread_setprio(A,B) SetThreadPriority(GetCurrentThread(), (B))
#define pthread_kill(A,B) pthread_dummy(0) #define pthread_kill(A,B) pthread_dummy(ESRCH)
#define pthread_join(A,B) (WaitForSingleObject((A), INFINITE) != WAIT_OBJECT_0) #define pthread_join(A,B) (WaitForSingleObject((A), INFINITE) != WAIT_OBJECT_0)
...@@ -361,14 +342,14 @@ struct tm *gmtime_r(const time_t *clock, struct tm *res); ...@@ -361,14 +342,14 @@ struct tm *gmtime_r(const time_t *clock, struct tm *res);
#define pthread_attr_setdetachstate(A,B) pthread_dummy(0) #define pthread_attr_setdetachstate(A,B) pthread_dummy(0)
#define pthread_create(A,B,C,D) pthread_create((A),*(B),(C),(D)) #define pthread_create(A,B,C,D) pthread_create((A),*(B),(C),(D))
#define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C)) #define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C))
#define pthread_kill(A,B) pthread_dummy(0) #define pthread_kill(A,B) pthread_dummy(ESRCH)
#undef pthread_detach_this_thread #undef pthread_detach_this_thread
#define pthread_detach_this_thread() { pthread_t tmp=pthread_self() ; pthread_detach(&tmp); } #define pthread_detach_this_thread() { pthread_t tmp=pthread_self() ; pthread_detach(&tmp); }
#endif #endif
#ifdef HAVE_DARWIN5_THREADS #ifdef HAVE_DARWIN5_THREADS
#define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C)) #define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C))
#define pthread_kill(A,B) pthread_dummy(0) #define pthread_kill(A,B) pthread_dummy(ESRCH)
#define pthread_condattr_init(A) pthread_dummy(0) #define pthread_condattr_init(A) pthread_dummy(0)
#define pthread_condattr_destroy(A) pthread_dummy(0) #define pthread_condattr_destroy(A) pthread_dummy(0)
#undef pthread_detach_this_thread #undef pthread_detach_this_thread
...@@ -388,7 +369,7 @@ struct tm *gmtime_r(const time_t *clock, struct tm *res); ...@@ -388,7 +369,7 @@ struct tm *gmtime_r(const time_t *clock, struct tm *res);
#ifndef pthread_sigmask #ifndef pthread_sigmask
#define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C)) #define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C))
#endif #endif
#define pthread_kill(A,B) pthread_dummy(0) #define pthread_kill(A,B) pthread_dummy(ESRCH)
#undef pthread_detach_this_thread #undef pthread_detach_this_thread
#define pthread_detach_this_thread() { pthread_t tmp=pthread_self() ; pthread_detach(&tmp); } #define pthread_detach_this_thread() { pthread_t tmp=pthread_self() ; pthread_detach(&tmp); }
#elif !defined(__NETWARE__) /* HAVE_PTHREAD_ATTR_CREATE && !HAVE_SIGWAIT */ #elif !defined(__NETWARE__) /* HAVE_PTHREAD_ATTR_CREATE && !HAVE_SIGWAIT */
...@@ -646,6 +627,11 @@ extern pthread_mutexattr_t my_errorcheck_mutexattr; ...@@ -646,6 +627,11 @@ extern pthread_mutexattr_t my_errorcheck_mutexattr;
#define MY_MUTEX_INIT_ERRCHK NULL #define MY_MUTEX_INIT_ERRCHK NULL
#endif #endif
#ifndef ESRCH
/* Define it to something */
#define ESRCH 1
#endif
typedef ulong my_thread_id; typedef ulong my_thread_id;
extern my_bool my_thread_global_init(void); extern my_bool my_thread_global_init(void);
......
...@@ -19,8 +19,6 @@ unlock tables; ...@@ -19,8 +19,6 @@ unlock tables;
show status like 'Table_locks_waited'; show status like 'Table_locks_waited';
Variable_name Value Variable_name Value
Table_locks_waited 1 Table_locks_waited 1
Immediate
17
drop table t1; drop table t1;
select 1; select 1;
1 1
......
...@@ -59,10 +59,6 @@ connection con1; ...@@ -59,10 +59,6 @@ connection con1;
reap; reap;
# ++Immediate = 16 + $wait_condition_reps # ++Immediate = 16 + $wait_condition_reps
show status like 'Table_locks_waited'; show status like 'Table_locks_waited';
# ++Immediate = 17 + $wait_condition_reps
--disable_query_log
eval select variable_value - $wait_condition_reps as Immediate from information_schema.session_status where variable_name like 'Table_locks_immediate';
--enable_query_log
drop table t1; drop table t1;
disconnect con2; disconnect con2;
......
...@@ -47,7 +47,7 @@ pthread_mutexattr_t my_fast_mutexattr; ...@@ -47,7 +47,7 @@ pthread_mutexattr_t my_fast_mutexattr;
pthread_mutexattr_t my_errorcheck_mutexattr; pthread_mutexattr_t my_errorcheck_mutexattr;
#endif #endif
#ifdef NPTL_PTHREAD_EXIT_BUG /* see my_pthread.h */ #ifdef TARGET_OS_LINUX
/* /*
Dummy thread spawned in my_thread_global_init() below to avoid Dummy thread spawned in my_thread_global_init() below to avoid
...@@ -61,7 +61,8 @@ nptl_pthread_exit_hack_handler(void *arg __attribute((unused))) ...@@ -61,7 +61,8 @@ nptl_pthread_exit_hack_handler(void *arg __attribute((unused)))
pthread_exit(0); pthread_exit(0);
return 0; return 0;
} }
#endif
#endif /* TARGET_OS_LINUX */
static uint get_thread_lib(void); static uint get_thread_lib(void);
...@@ -88,7 +89,7 @@ my_bool my_thread_global_init(void) ...@@ -88,7 +89,7 @@ my_bool my_thread_global_init(void)
return 1; return 1;
} }
#ifdef NPTL_PTHREAD_EXIT_BUG #ifdef TARGET_OS_LINUX
/* /*
BUG#24507: Race conditions inside current NPTL pthread_exit() BUG#24507: Race conditions inside current NPTL pthread_exit()
implementation. implementation.
...@@ -112,7 +113,7 @@ my_bool my_thread_global_init(void) ...@@ -112,7 +113,7 @@ my_bool my_thread_global_init(void)
pthread_create(&dummy_thread,&dummy_thread_attr, pthread_create(&dummy_thread,&dummy_thread_attr,
nptl_pthread_exit_hack_handler, NULL); nptl_pthread_exit_hack_handler, NULL);
} }
#endif #endif /* TARGET_OS_LINUX */
#ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP #ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
/* /*
...@@ -179,10 +180,17 @@ void my_thread_global_end(void) ...@@ -179,10 +180,17 @@ void my_thread_global_end(void)
&abstime); &abstime);
if (error == ETIMEDOUT || error == ETIME) if (error == ETIMEDOUT || error == ETIME)
{ {
#ifdef HAVE_PTHREAD_KILL
/*
We shouldn't give an error here, because if we don't have
pthread_kill(), programs like mysqld can't ensure that all threads
are killed when we enter here.
*/
if (THR_thread_count) if (THR_thread_count)
fprintf(stderr, fprintf(stderr,
"Error in my_thread_global_end(): %d threads didn't exit\n", "Error in my_thread_global_end(): %d threads didn't exit\n",
THR_thread_count); THR_thread_count);
#endif
all_threads_killed= 0; all_threads_killed= 0;
break; break;
} }
...@@ -208,7 +216,7 @@ void my_thread_global_end(void) ...@@ -208,7 +216,7 @@ void my_thread_global_end(void)
if (all_threads_killed) if (all_threads_killed)
{ {
pthread_mutex_destroy(&THR_LOCK_threads); pthread_mutex_destroy(&THR_LOCK_threads);
pthread_cond_destroy (&THR_COND_threads); pthread_cond_destroy(&THR_COND_threads);
} }
#if !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R) #if !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R)
pthread_mutex_destroy(&LOCK_localtime_r); pthread_mutex_destroy(&LOCK_localtime_r);
......
...@@ -7016,6 +7016,7 @@ int Write_rows_log_event::do_after_row_operations(TABLE *table, int error) ...@@ -7016,6 +7016,7 @@ int Write_rows_log_event::do_after_row_operations(TABLE *table, int error)
return error? error : local_error; return error? error : local_error;
} }
int Write_rows_log_event::do_prepare_row(THD *thd_arg, int Write_rows_log_event::do_prepare_row(THD *thd_arg,
Relay_log_info const *rli, Relay_log_info const *rli,
TABLE *table, TABLE *table,
......
...@@ -1288,7 +1288,7 @@ static void wait_for_signal_thread_to_end() ...@@ -1288,7 +1288,7 @@ static void wait_for_signal_thread_to_end()
*/ */
for (i= 0 ; i < 100 && signal_thread_in_use; i++) for (i= 0 ; i < 100 && signal_thread_in_use; i++)
{ {
if (pthread_kill(signal_thread, MYSQL_KILL_SIGNAL)) if (pthread_kill(signal_thread, MYSQL_KILL_SIGNAL) != ESRCH)
break; break;
my_sleep(100); // Give it time to die my_sleep(100); // Give it time to die
} }
......
...@@ -4501,6 +4501,7 @@ create_table_option: ...@@ -4501,6 +4501,7 @@ create_table_option:
Lex->create_info.transactional= ($3 != 0 ? HA_CHOICE_YES : Lex->create_info.transactional= ($3 != 0 ? HA_CHOICE_YES :
HA_CHOICE_NO); HA_CHOICE_NO);
} }
; ;
default_charset: default_charset:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment