From 5015633178490d0b2238cefa24c583b0d7d10965 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Wed, 28 Mar 2012 14:46:03 +0300 Subject: [PATCH 1/4] Applied patch for guard stack for PPC/IA64 by Maarten Vanraes (lp:886368) --- sql/mysqld.cc | 108 +++++++++++++++++++++++++++++++------------------- 1 file changed, 68 insertions(+), 40 deletions(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index a73177f9fea..d524dde3c91 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2852,6 +2852,70 @@ static void init_signals(void) } +/* pthread_attr_setstacksize without so much platform-dependency */ +/* returns the actual stack size if possible */ +static size_t my_setstacksize(pthread_attr_t *attr, size_t stacksize) +{ + size_t guard_size = 0; + +#if defined(__ia64__) || defined(__ia64) + /* + On IA64, half of the requested stack size is used for "normal stack" + and half for "register stack". The space measured by check_stack_overrun + is the "normal stack", so double the request to make sure we have the + caller-expected amount of normal stack. + + NOTE: there is no guarantee that the register stack can't grow faster + than normal stack, so it's very unclear that we won't dump core due to + stack overrun despite check_stack_overrun's efforts. Experimentation + shows that in the execution_constants test, the register stack grows + less than half as fast as normal stack, but perhaps other scenarios are + less forgiving. If it turns out that more space is needed for the + register stack, that could be forced (rather inefficiently) by using a + multiplier higher than 2 here. + */ + stacksize *= 2; +#endif + + /* + On many machines, the "guard space" is subtracted from the requested + stack size, and that space is quite large on some platforms. So add + it to our request, if we can find out what it is. + + FIXME: autoconfiscate use of pthread_attr_getguardsize + */ + if (pthread_attr_getguardsize(attr, &guard_size)) + guard_size = 0; /* if can't find it out, treat as 0 */ + + pthread_attr_setstacksize(attr, stacksize + guard_size); + + /* Retrieve actual stack size if possible */ +#ifdef HAVE_PTHREAD_ATTR_GETSTACKSIZE + { + size_t real_stack_size= 0; + /* We must ignore real_stack_size = 0 as Solaris 2.9 can return 0 here */ + if (pthread_attr_getstacksize(attr, &real_stack_size) == 0 && + real_stack_size > guard_size) + { + real_stack_size -= guard_size; + if (real_stack_size < stacksize) + { + if (global_system_variables.log_warnings) + sql_print_warning("Asked for %zu thread stack, but got %zu", + stacksize, real_stack_size); + stacksize= real_stack_size; + } + } + } +#endif + +#if defined(__ia64__) || defined(__ia64) + stacksize /= 2; +#endif + return stacksize; +} + + static void start_signal_handler(void) { int error; @@ -2862,15 +2926,7 @@ static void start_signal_handler(void) #if !defined(HAVE_DEC_3_2_THREADS) pthread_attr_setscope(&thr_attr,PTHREAD_SCOPE_SYSTEM); (void) pthread_attr_setdetachstate(&thr_attr,PTHREAD_CREATE_DETACHED); -#if defined(__ia64__) || defined(__ia64) - /* - Peculiar things with ia64 platforms - it seems we only have half the - stack size in reality, so we have to double it here - */ - pthread_attr_setstacksize(&thr_attr,my_thread_stack_size*2); -#else - pthread_attr_setstacksize(&thr_attr,my_thread_stack_size); -#endif + (void) my_setstacksize(&thr_attr,my_thread_stack_size); #endif mysql_mutex_lock(&LOCK_thread_count); @@ -4694,37 +4750,9 @@ int mysqld_main(int argc, char **argv) unireg_abort(1); // Will do exit init_signals(); -#if defined(__ia64__) || defined(__ia64) - /* - Peculiar things with ia64 platforms - it seems we only have half the - stack size in reality, so we have to double it here - */ - pthread_attr_setstacksize(&connection_attrib,my_thread_stack_size*2); -#else - pthread_attr_setstacksize(&connection_attrib,my_thread_stack_size); -#endif -#ifdef HAVE_PTHREAD_ATTR_GETSTACKSIZE - { - /* Retrieve used stack size; Needed for checking stack overflows */ - size_t stack_size= 0; - pthread_attr_getstacksize(&connection_attrib, &stack_size); -#if defined(__ia64__) || defined(__ia64) - stack_size/= 2; -#endif - /* We must check if stack_size = 0 as Solaris 2.9 can return 0 here */ - if (stack_size && stack_size < my_thread_stack_size) - { - if (global_system_variables.log_warnings) - sql_print_warning("Asked for %llu thread stack, but got %zu", - my_thread_stack_size, stack_size); -#if defined(__ia64__) || defined(__ia64) - my_thread_stack_size= stack_size*2; -#else - my_thread_stack_size= stack_size; -#endif - } - } -#endif + + my_thread_stack_size= my_setstacksize(&connection_attrib, + my_thread_stack_size); (void) thr_setconcurrency(concurrency); // 10 by default From 3c0deee3fa0de2b71e70e37a5cd945af9ee9f392 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Mon, 2 Apr 2012 10:53:09 +0300 Subject: [PATCH 2/4] Partial fix for lp:886476 [PATCH] disable tests By Maarten Vanraes mysql-test/suite/innodb/r/innodb.result: Make result portable mysql-test/suite/innodb/t/innodb.test: Make result portable --- mysql-test/suite/innodb/r/innodb.result | 2 +- mysql-test/suite/innodb/t/innodb.test | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/suite/innodb/r/innodb.result b/mysql-test/suite/innodb/r/innodb.result index 2ec6c91f7d5..bb4d783ccf4 100644 --- a/mysql-test/suite/innodb/r/innodb.result +++ b/mysql-test/suite/innodb/r/innodb.result @@ -1685,7 +1685,7 @@ count(*) drop table t1; SELECT variable_value FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_buffer_pool_pages_total'; variable_value -511 +ok SELECT variable_value FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_page_size'; variable_value 16384 diff --git a/mysql-test/suite/innodb/t/innodb.test b/mysql-test/suite/innodb/t/innodb.test index c2309c0fcd6..d57a52a2362 100644 --- a/mysql-test/suite/innodb/t/innodb.test +++ b/mysql-test/suite/innodb/t/innodb.test @@ -1339,7 +1339,7 @@ drop table t1; # Test for testable InnoDB status variables. This test # uses previous ones(pages_created, rows_deleted, ...). ---replace_result 512 511 2047 511 +--replace_result 511 ok 512 ok 2047 ok 513 ok SELECT variable_value FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_buffer_pool_pages_total'; SELECT variable_value FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_page_size'; SELECT variable_value - @innodb_rows_deleted_orig FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_rows_deleted'; From 2887bfbe9e6ab954a9603a87d151915c5a9dfa96 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Mon, 2 Apr 2012 12:09:22 +0300 Subject: [PATCH 3/4] Fixed lp:886484 "nowatch option for mysqld (allow systemd)" Added a --nowatch (with aliases --no-watch and --no-auto-restart) option to mysqld_safe that causes it to exit after spawning mysqld. We don't need mysqld_safe to restart mysqld after a crash, because systemd can do that just fine. Based on code from Maarten Vanraes scripts/mysqld_safe.sh: Added option --nowatch (with aliases --no-watch and --no-auto-restart) --- scripts/mysqld_safe.sh | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/scripts/mysqld_safe.sh b/scripts/mysqld_safe.sh index 20e5e115687..aaf1936afe1 100644 --- a/scripts/mysqld_safe.sh +++ b/scripts/mysqld_safe.sh @@ -15,6 +15,7 @@ KILL_MYSQLD=1; MYSQLD= niceness=0 +nowatch=0 mysqld_ld_preload= mysqld_ld_library_path= @@ -44,16 +45,18 @@ usage () { cat < Date: Mon, 2 Apr 2012 12:30:14 +0300 Subject: [PATCH 4/4] Ignore install_manifest.txt (created by 'make install') --- .bzrignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.bzrignore b/.bzrignore index 68d45ea93b0..f757e602563 100644 --- a/.bzrignore +++ b/.bzrignore @@ -1139,3 +1139,4 @@ libmysqld/gcalc_slicescan.cc libmysqld/gcalc_tools.cc sql/share/errmsg.sys sql/share/mysql +install_manifest.txt