From cdd5a353c4d0443e207a97a99fe05ed3eb2cbd37 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 20 Dec 2006 17:42:44 +0100 Subject: [PATCH 1/7] BUG#20061 build script can not detect my cpu BUILD/check-cpu: add a handful of Celeroni and automatic fallback to uname if /proc/cpuinfo is there but we don't understand the information in it --- BUILD/check-cpu | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/BUILD/check-cpu b/BUILD/check-cpu index e207d12d972..bde6879e664 100755 --- a/BUILD/check-cpu +++ b/BUILD/check-cpu @@ -5,9 +5,13 @@ # check_cpu () { - if test -r /proc/cpuinfo ; then + CPUINFO=/proc/cpuinfo + if test -n "$TEST_CPUINFO" ; then + CPUINFO=$TEST_CPUINFO + fi + if test -r "$CPUINFO" -a "$CPUINFO" != " " ; then # on Linux (and others?) we can get detailed CPU information out of /proc - cpuinfo="cat /proc/cpuinfo" + cpuinfo="cat $CPUINFO" # detect CPU family cpu_family=`$cpuinfo | grep 'family' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1` @@ -33,6 +37,7 @@ check_cpu () { done else # Fallback when there is no /proc/cpuinfo + CPUINFO=" " case "`uname -s`" in FreeBSD|OpenBSD) cpu_family=`uname -m`; @@ -84,6 +89,18 @@ check_cpu () { *Pentium*M*pro*) cpu_arg="pentium-m"; ;; + *Celeron\(R\)*\ M*) + cpu_arg="pentium-m"; + ;; + *Celeron*Coppermine*) + cpu_arg="pentium3" + ;; + *Celeron\(R\)*) + cpu_arg="pentium4" + ;; + *Celeron*) + cpu_arg="pentium2"; + ;; *Athlon*64*) cpu_arg="athlon64"; ;; @@ -113,7 +130,14 @@ check_cpu () { esac - if test -z "$cpu_arg"; then + if test -z "$cpu_arg" ; then + if test "$CPUINFO" != " " ; then + # fallback to uname if necessary + TEST_CPUINFO=" " + check_cpu_cflags="" + check_cpu + return + fi echo "BUILD/check-cpu: Oops, could not find out what kind of cpu this machine is using." >&2 check_cpu_cflags="" return From 81cf3b8051bfda2c23cc96fa78c6362253fa48ff Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 9 Jan 2007 09:32:56 +0100 Subject: [PATCH 2/7] BUG#24780 workaround for broken installations that depend on using /etc, but were configured differently scripts/mysqlaccess.sh: also look in /etc scripts/mysqld_multi.sh: also look in /etc --- scripts/mysqlaccess.sh | 4 ++++ scripts/mysqld_multi.sh | 3 +++ 2 files changed, 7 insertions(+) diff --git a/scripts/mysqlaccess.sh b/scripts/mysqlaccess.sh index 22e9d121f9a..bcaf9f8af8e 100644 --- a/scripts/mysqlaccess.sh +++ b/scripts/mysqlaccess.sh @@ -465,6 +465,9 @@ MySQLaccess::Report::Print_Header(); elsif (-f "@sysconfdir@/$script_conf") { require "@sysconfdir@/$script_conf"; } + elsif (-f "/etc/$script_conf") { + require "/etc/$script_conf"; + } # **************************** # Read in all parameters @@ -930,6 +933,7 @@ sub MergeConfigFile { sub MergeConfigFiles { my ($name,$pass,$uid,$gid,$quota,$comment,$gcos,$dir,$shell) = getpwuid $<; MergeConfigFile("@sysconfdir@/my.cnf"); + MergeConfigFile("/etc/my.cnf"); MergeConfigFile("$dir/.my.cnf"); } diff --git a/scripts/mysqld_multi.sh b/scripts/mysqld_multi.sh index ce778c03206..8b435161e47 100644 --- a/scripts/mysqld_multi.sh +++ b/scripts/mysqld_multi.sh @@ -432,6 +432,9 @@ sub find_groups if (-f "@sysconfdir@/my.cnf" && -r "@sysconfdir@/my.cnf") { open(MY_CNF, "<@sysconfdir@/my.cnf") && (@tmp=) && close(MY_CNF); + } elsif (-f "/etc/my.cnf" && -r "/etc/my.cnf") + { + open(MY_CNF, ") && close(MY_CNF); } for ($i = 0; ($line = shift @tmp); $i++) { From 1c24fc316334ca65d6c6d699981925118f7639f0 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 17 Jan 2007 10:06:50 +0100 Subject: [PATCH 3/7] ha_ndbcluster.cc: Bug #25668 ndb: mysqld may core if cluster disconnected -- pTrans may be NULL, remove not needed usage of handler::ndb_err sql/ha_ndbcluster.cc: Bug #25668 ndb: mysqld may core if cluster disconnected -- pTrans may be NULL, remove not needed usage of handler::ndb_err --- sql/ha_ndbcluster.cc | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 0f580c833a9..c40404f0219 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -6109,23 +6109,7 @@ ndb_get_table_statistics(ha_ndbcluster* file, bool report_error, Ndb* ndb, DBUG_RETURN(0); retry: - if(report_error) - { - if (file) - { - reterr= file->ndb_err(pTrans); - } - else - { - const NdbError& tmp= error; - ERR_PRINT(tmp); - reterr= ndb_to_mysql_error(&tmp); - } - } - else - reterr= error.code; - if (pTrans) { ndb->closeTransaction(pTrans); pTrans= NULL; @@ -6135,6 +6119,15 @@ retry: my_sleep(retry_sleep); continue; } + if(report_error) + { + const NdbError& tmp= error; + ERR_PRINT(tmp); + reterr= ndb_to_mysql_error(&tmp); + } + else + reterr= error.code; + break; } while(1); DBUG_PRINT("exit", ("failed, reterr: %u, NdbError %u(%s)", reterr, From 15eebdc0a1549c9af5be4a053f192f21365ab479 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 17 Jan 2007 10:41:52 +0100 Subject: [PATCH 4/7] ha_ndbcluster.cc: Bug #25668 - corrected patch after test failures sql/ha_ndbcluster.cc: Bug #25668 - corrected patch after test failures --- sql/ha_ndbcluster.cc | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index c40404f0219..f0ae4bae3a2 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -6109,7 +6109,23 @@ ndb_get_table_statistics(ha_ndbcluster* file, bool report_error, Ndb* ndb, DBUG_RETURN(0); retry: + if(report_error) + { + if (file && pTrans) + { + reterr= file->ndb_err(pTrans); + } + else + { + const NdbError& tmp= error; + ERR_PRINT(tmp); + reterr= ndb_to_mysql_error(&tmp); + } + } + else + reterr= error.code; + if (pTrans) { ndb->closeTransaction(pTrans); pTrans= NULL; @@ -6119,15 +6135,6 @@ retry: my_sleep(retry_sleep); continue; } - if(report_error) - { - const NdbError& tmp= error; - ERR_PRINT(tmp); - reterr= ndb_to_mysql_error(&tmp); - } - else - reterr= error.code; - break; } while(1); DBUG_PRINT("exit", ("failed, reterr: %u, NdbError %u(%s)", reterr, From 87a569f3c0366621dac586c4514d1370080f9478 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 19 Jan 2007 11:58:29 +0100 Subject: [PATCH 5/7] cmd-line-utils/readline/undo.c : Replace an "uint" cast by the expanded "unsigned int" (compile problem on QNX). cmd-line-utils/readline/undo.c: Replace an "uint" cast by the expanded "unsigned int", because there are platforms (QNX) on which "uint" is not defined in the "readline" library (and so building it failed, version 5.0.34). --- cmd-line-utils/readline/undo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd-line-utils/readline/undo.c b/cmd-line-utils/readline/undo.c index b4b5a6511ba..4d256f492b8 100644 --- a/cmd-line-utils/readline/undo.c +++ b/cmd-line-utils/readline/undo.c @@ -175,7 +175,7 @@ _rl_fix_last_undo_of_type (type, start, end) for (rl = rl_undo_list; rl; rl = rl->next) { - if (rl->what == (uint) type) + if (rl->what == (unsigned int) type) { rl->start = start; rl->end = end; From 4f69569dfa77e9115418ce4b1982ec00a106a660 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 22 Jan 2007 16:32:57 +0100 Subject: [PATCH 6/7] after-merge fix --- mysql-test/mysql-test-run.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 8cb33f9aaac..436030383e1 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -1046,7 +1046,7 @@ sub command_line_setup () { # On some operating systems, there is a limit to the length of a # UNIX domain socket's path far below PATH_MAX, so try to avoid long # socket path names. - $sockdir = tempdir(CLEANUP => 1) if ( length($sockdir) > 80 ); + $sockdir = tempdir(CLEANUP => 0) if ( length($sockdir) > 80 ); # Put this into a hash, will be a C struct From d48e864f2faf06867988e5b9b9346a56fb86b818 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 23 Jan 2007 05:09:14 -0800 Subject: [PATCH 7/7] Bug#25396 "Valgrind leak in closecon_handlerton" plugin_shutdown() calls plugin_deinitialize() which calls ha_finalize_handlerton(). ndbcluster_end() fails to wait for the ndb utility thread to exit which results in the handlerton struct being freed before the ndb utility thread has destroyed it's THD but before the plugin has been marked as UNINITIALIZED Bug is caused by misuse of abort_loops variable and not locking mutex during calls to pthread condition variable functions causing a race in valgrind's pthread_cond_wait implementation. sql/ha_ndbcluster.cc: Bug25396 Valgrind requires that mutex be held during call to pthread_cond_signal. Change pthread_cond_timedwait() to pthread_cond_wait() where the timeout is not needed. Ensure that appropiate variables are protected by mutex. Remove use of abort_loop global variable. Ensure that ndbcluster_end waits for util thread to exit. Add an extra cond_var as insurance against non-conforming pthreads implementations. sql/mysqld.cc: Bug25386 Valgrind requires that mutex be held during call to pthread_cond_signal. BUILD/compile-amd64-valgrind-max: New BitKeeper file ``BUILD/compile-amd64-valgrind-max'' --- BUILD/compile-amd64-valgrind-max | 24 +++++++ sql/ha_ndbcluster.cc | 113 ++++++++++++++++++------------- sql/mysqld.cc | 11 +-- 3 files changed, 98 insertions(+), 50 deletions(-) create mode 100755 BUILD/compile-amd64-valgrind-max diff --git a/BUILD/compile-amd64-valgrind-max b/BUILD/compile-amd64-valgrind-max new file mode 100755 index 00000000000..962d0f17b04 --- /dev/null +++ b/BUILD/compile-amd64-valgrind-max @@ -0,0 +1,24 @@ +#! /bin/sh + +path=`dirname $0` +. "$path/SETUP.sh" + +extra_flags="$amd64_cflags $debug_cflags $valgrind_flags" +extra_configs="$amd64_configs $debug_configs $max_configs" + +. "$path/FINISH.sh" + +if test -z "$just_print" +then + set +v +x + echo "\ +****************************************************************************** +Note that by default BUILD/compile-pentium-valgrind-max calls 'configure' with +--enable-assembler. When Valgrind detects an error involving an assembly +function (for example an uninitialized value used as an argument of an +assembly function), Valgrind will not print the stacktrace and 'valgrind +--gdb-attach=yes' will not work either. If you need a stacktrace in those +cases, you have to run BUILD/compile-pentium-valgrind-max with the +--disable-assembler argument. +******************************************************************************" +fi diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 5614cc3ecd8..07887c2ac1f 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -133,6 +133,7 @@ static uint ndbcluster_alter_table_flags(uint flags) } static int ndbcluster_inited= 0; +static int ndbcluster_terminating= 0; static Ndb* g_ndb= NULL; Ndb_cluster_connection* g_ndb_cluster_connection= NULL; @@ -159,6 +160,7 @@ pthread_t ndb_util_thread; int ndb_util_thread_running= 0; pthread_mutex_t LOCK_ndb_util_thread; pthread_cond_t COND_ndb_util_thread; +pthread_cond_t COND_ndb_util_ready; pthread_handler_t ndb_util_thread_func(void *arg); ulong ndb_cache_check_time; @@ -6588,6 +6590,7 @@ int ndbcluster_find_files(handlerton *hton, THD *thd, /* Call back after cluster connect */ static int connect_callback() { + pthread_mutex_lock(&LOCK_ndb_util_thread); update_status_variables(g_ndb_cluster_connection); uint node_id, i= 0; @@ -6597,6 +6600,7 @@ static int connect_callback() g_node_id_map[node_id]= i++; pthread_cond_signal(&COND_ndb_util_thread); + pthread_mutex_unlock(&LOCK_ndb_util_thread); return 0; } @@ -6607,6 +6611,15 @@ static int ndbcluster_init(void *p) int res; DBUG_ENTER("ndbcluster_init"); + if (ndbcluster_inited) + DBUG_RETURN(FALSE); + + pthread_mutex_init(&ndbcluster_mutex,MY_MUTEX_INIT_FAST); + pthread_mutex_init(&LOCK_ndb_util_thread, MY_MUTEX_INIT_FAST); + pthread_cond_init(&COND_ndb_util_thread, NULL); + pthread_cond_init(&COND_ndb_util_ready, NULL); + ndb_util_thread_running= -1; + ndbcluster_terminating= 0; ndb_dictionary_is_mysqld= 1; ndbcluster_hton= (handlerton *)p; @@ -6705,17 +6718,12 @@ static int ndbcluster_init(void *p) (void) hash_init(&ndbcluster_open_tables,system_charset_info,32,0,0, (hash_get_key) ndbcluster_get_key,0,0); - pthread_mutex_init(&ndbcluster_mutex,MY_MUTEX_INIT_FAST); #ifdef HAVE_NDB_BINLOG /* start the ndb injector thread */ if (ndbcluster_binlog_start()) goto ndbcluster_init_error; #endif /* HAVE_NDB_BINLOG */ - pthread_mutex_init(&LOCK_ndb_util_thread, MY_MUTEX_INIT_FAST); - pthread_cond_init(&COND_ndb_util_thread, NULL); - - ndb_cache_check_time = opt_ndb_cache_check_time; // Create utility thread pthread_t tmp; @@ -6726,14 +6734,26 @@ static int ndbcluster_init(void *p) pthread_mutex_destroy(&ndbcluster_mutex); pthread_mutex_destroy(&LOCK_ndb_util_thread); pthread_cond_destroy(&COND_ndb_util_thread); + pthread_cond_destroy(&COND_ndb_util_ready); goto ndbcluster_init_error; } /* Wait for the util thread to start */ pthread_mutex_lock(&LOCK_ndb_util_thread); - while (!ndb_util_thread_running) - pthread_cond_wait(&COND_ndb_util_thread, &LOCK_ndb_util_thread); + while (ndb_util_thread_running < 0) + pthread_cond_wait(&COND_ndb_util_ready, &LOCK_ndb_util_thread); pthread_mutex_unlock(&LOCK_ndb_util_thread); + + if (!ndb_util_thread_running) + { + DBUG_PRINT("error", ("ndb utility thread exited prematurely")); + hash_free(&ndbcluster_open_tables); + pthread_mutex_destroy(&ndbcluster_mutex); + pthread_mutex_destroy(&LOCK_ndb_util_thread); + pthread_cond_destroy(&COND_ndb_util_thread); + pthread_cond_destroy(&COND_ndb_util_ready); + goto ndbcluster_init_error; + } ndbcluster_inited= 1; DBUG_RETURN(FALSE); @@ -6760,22 +6780,12 @@ static int ndbcluster_end(handlerton *hton, ha_panic_function type) ndbcluster_inited= 0; /* wait for util thread to finish */ + sql_print_information("Stopping Cluster Utility thread"); pthread_mutex_lock(&LOCK_ndb_util_thread); - if (ndb_util_thread_running > 0) - { - pthread_cond_signal(&COND_ndb_util_thread); - pthread_mutex_unlock(&LOCK_ndb_util_thread); - - pthread_mutex_lock(&LOCK_ndb_util_thread); - while (ndb_util_thread_running > 0) - { - struct timespec abstime; - set_timespec(abstime, 1); - pthread_cond_timedwait(&COND_ndb_util_thread, - &LOCK_ndb_util_thread, - &abstime); - } - } + ndbcluster_terminating= 1; + pthread_cond_signal(&COND_ndb_util_thread); + while (ndb_util_thread_running > 0) + pthread_cond_wait(&COND_ndb_util_ready, &LOCK_ndb_util_thread); pthread_mutex_unlock(&LOCK_ndb_util_thread); @@ -6824,6 +6834,7 @@ static int ndbcluster_end(handlerton *hton, ha_panic_function type) pthread_mutex_destroy(&ndbcluster_mutex); pthread_mutex_destroy(&LOCK_ndb_util_thread); pthread_cond_destroy(&COND_ndb_util_thread); + pthread_cond_destroy(&COND_ndb_util_ready); DBUG_RETURN(0); } @@ -8357,6 +8368,8 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused))) my_thread_init(); DBUG_ENTER("ndb_util_thread"); DBUG_PRINT("enter", ("ndb_cache_check_time: %lu", ndb_cache_check_time)); + + pthread_mutex_lock(&LOCK_ndb_util_thread); thd= new THD; /* note that contructor of THD uses DBUG_ */ THD_CHECK_SENTRY(thd); @@ -8366,12 +8379,7 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused))) thd->thread_stack= (char*)&thd; /* remember where our stack is */ if (thd->store_globals()) - { - thd->cleanup(); - delete thd; - ndb_util_thread_running= 0; - DBUG_RETURN(NULL); - } + goto ndb_util_thread_fail; thd->init_for_queries(); thd->version=refresh_version; thd->set_time(); @@ -8382,15 +8390,27 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused))) thd->main_security_ctx.priv_user = 0; thd->current_stmt_binlog_row_based= TRUE; // If in mixed mode + /* Signal successful initialization */ ndb_util_thread_running= 1; - pthread_cond_signal(&COND_ndb_util_thread); + pthread_cond_signal(&COND_ndb_util_ready); + pthread_mutex_unlock(&LOCK_ndb_util_thread); /* wait for mysql server to start */ pthread_mutex_lock(&LOCK_server_started); while (!mysqld_server_started) - pthread_cond_wait(&COND_server_started, &LOCK_server_started); + { + set_timespec(abstime, 1); + pthread_cond_timedwait(&COND_server_started, &LOCK_server_started, + &abstime); + if (ndbcluster_terminating) + { + pthread_mutex_unlock(&LOCK_server_started); + pthread_mutex_lock(&LOCK_ndb_util_thread); + goto ndb_util_thread_end; + } + } pthread_mutex_unlock(&LOCK_server_started); /* @@ -8400,15 +8420,9 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused))) while (!ndb_cluster_node_id && (ndbcluster_hton->slot != ~(uint)0)) { /* ndb not connected yet */ - set_timespec(abstime, 1); - pthread_cond_timedwait(&COND_ndb_util_thread, - &LOCK_ndb_util_thread, - &abstime); - if (abort_loop) - { - pthread_mutex_unlock(&LOCK_ndb_util_thread); + pthread_cond_wait(&COND_ndb_util_thread, &LOCK_ndb_util_thread); + if (ndbcluster_terminating) goto ndb_util_thread_end; - } } pthread_mutex_unlock(&LOCK_ndb_util_thread); @@ -8416,6 +8430,7 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused))) if (!(thd_ndb= ha_ndbcluster::seize_thd_ndb())) { sql_print_error("Could not allocate Thd_ndb object"); + pthread_mutex_lock(&LOCK_ndb_util_thread); goto ndb_util_thread_end; } set_thd_ndb(thd, thd_ndb); @@ -8434,19 +8449,20 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused))) #endif set_timespec(abstime, 0); - for (;!abort_loop;) + for (;;) { pthread_mutex_lock(&LOCK_ndb_util_thread); - pthread_cond_timedwait(&COND_ndb_util_thread, - &LOCK_ndb_util_thread, - &abstime); + if (!ndbcluster_terminating) + pthread_cond_timedwait(&COND_ndb_util_thread, + &LOCK_ndb_util_thread, + &abstime); + if (ndbcluster_terminating) /* Shutting down server */ + goto ndb_util_thread_end; pthread_mutex_unlock(&LOCK_ndb_util_thread); #ifdef NDB_EXTRA_DEBUG_UTIL_THREAD DBUG_PRINT("ndb_util_thread", ("Started, ndb_cache_check_time: %lu", ndb_cache_check_time)); #endif - if (abort_loop) - break; /* Shutting down server */ #ifdef HAVE_NDB_BINLOG /* @@ -8569,13 +8585,18 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused))) abstime.tv_nsec-= 1000000000; } } + + pthread_mutex_lock(&LOCK_ndb_util_thread); + ndb_util_thread_end: - sql_print_information("Stopping Cluster Utility thread"); net_end(&thd->net); +ndb_util_thread_fail: thd->cleanup(); delete thd; - pthread_mutex_lock(&LOCK_ndb_util_thread); + + /* signal termination */ ndb_util_thread_running= 0; + pthread_cond_signal(&COND_ndb_util_ready); pthread_mutex_unlock(&LOCK_ndb_util_thread); DBUG_PRINT("exit", ("ndb_util_thread")); my_thread_end(); diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 72add4d3aa4..2be5c2b342b 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -3706,15 +3706,18 @@ we force server id to 2, but this MySQL server will not act as a slave."); mysqld_port, MYSQL_COMPILATION_COMMENT); - // Signal threads waiting for server to be started - mysqld_server_started= 1; - pthread_cond_signal(&COND_server_started); - if (!opt_noacl) { if (Events::get_instance()->init()) unireg_abort(1); } + + /* Signal threads waiting for server to be started */ + pthread_mutex_lock(&LOCK_server_started); + mysqld_server_started= 1; + pthread_cond_signal(&COND_server_started); + pthread_mutex_unlock(&LOCK_server_started); + #if defined(__NT__) || defined(HAVE_SMEM) handle_connections_methods(); #else