From 796672c44b350a856621193a5b67e5e91aef38e3 Mon Sep 17 00:00:00 2001 From: Joerg Bruehe Date: Thu, 3 Feb 2011 18:16:22 +0100 Subject: [PATCH 1/5] Fix Bug #56581 RPM scripts use hardcoded datadir location When fixing the 27072 bug, the shell snippets running before/after a RPM upgrade got expanded to look at files in the data directory and at the PID file. In this expansion, the standard locations were used. There are users who configure their installations to use non-standard locations for the data directory, the PID file, and other objects. For these users, the fix of 27072 did not work. As a result, the fact that a server was running at upgrade start was not noticed, and the new server was not started after the upgrade. With this patch, the shell snippets now try to get these locations from "my_print_defaults" before falling back to the defaults. Now, the fact that the old server is running is again noticed (even with non-standard locations), and the new server is started. Also, the upgrade log is written to the correct data directory. --- support-files/mysql.spec.sh | 58 ++++++++++++++++++++++++++++++------- 1 file changed, 48 insertions(+), 10 deletions(-) diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index c69ae6afce0..33c1254bc15 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -1,4 +1,4 @@ -# Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -610,7 +610,25 @@ touch $RBR%{_sysconfdir}/mysqlmanager.passwd ############################################################################## %pre server -mysql_datadir=%{mysqldatadir} +# This is the code running at the beginning of a RPM upgrade action, +# before replacing the old files with the new ones. + +# There are users who deviate from the default file system layout. +# Check local settings to support them. +if [ -x %{_bindir}/my_print_defaults ] +then + mysql_datadir=`%{_bindir}/my_print_defaults server mysqld | grep '^--datadir=' | sed -n 's/--datadir=//p'` + PID_FILE_PATT=`%{_bindir}/my_print_defaults server mysqld | grep '^--pid-file=' | sed -n 's/--pid-file=//p'` +fi +if [ -z "$mysql_datadir" ] +then + mysql_datadir=%{mysqldatadir} +fi +if [ -z "$PID_FILE_PATT" ] +then + PID_FILE_PATT="$mysql_datadir/*.pid" +fi + # Check if we can safely upgrade. An upgrade is only safe if it's from one # of our RPMs in the same version family. @@ -681,7 +699,7 @@ fi # We assume that if there is exactly one ".pid" file, # it contains the valid PID of a running MySQL server. -NR_PID_FILES=`ls $mysql_datadir/*.pid 2>/dev/null | wc -l` +NR_PID_FILES=`ls $PID_FILE_PATT 2>/dev/null | wc -l` case $NR_PID_FILES in 0 ) SERVER_TO_START='' ;; # No "*.pid" file == no running server 1 ) SERVER_TO_START='true' ;; @@ -703,8 +721,8 @@ if [ -f $STATUS_FILE ]; then echo "before repeating the MySQL upgrade." exit 1 elif [ -n "$SEVERAL_PID_FILES" ] ; then - echo "Your MySQL directory '$mysql_datadir' has more than one PID file:" - ls -ld $mysql_datadir/*.pid + echo "You have more than one PID file:" + ls -ld $PID_FILE_PATT echo "Please check which one (if any) corresponds to a running server" echo "and delete all others before repeating the MySQL upgrade." exit 1 @@ -729,17 +747,17 @@ if [ -d $mysql_datadir ] ; then if [ -n "$SERVER_TO_START" ] ; then # There is only one PID file, race possibility ignored echo "PID file:" >> $STATUS_FILE - ls -l $mysql_datadir/*.pid >> $STATUS_FILE - cat $mysql_datadir/*.pid >> $STATUS_FILE + ls -l $PID_FILE_PATT >> $STATUS_FILE + cat $PID_FILE_PATT >> $STATUS_FILE echo >> $STATUS_FILE echo "Server process:" >> $STATUS_FILE - ps -fp `cat $mysql_datadir/*.pid` >> $STATUS_FILE + ps -fp `cat $PID_FILE_PATT` >> $STATUS_FILE echo >> $STATUS_FILE echo "SERVER_TO_START=$SERVER_TO_START" >> $STATUS_FILE else # Take a note we checked it ... echo "PID file:" >> $STATUS_FILE - ls -l $mysql_datadir/*.pid >> $STATUS_FILE 2>&1 + ls -l $PID_FILE_PATT >> $STATUS_FILE 2>&1 fi fi @@ -754,7 +772,20 @@ if [ -x %{_sysconfdir}/init.d/mysql ] ; then fi %post server -mysql_datadir=%{mysqldatadir} +# This is the code running at the end of a RPM install or upgrade action, +# after the (new) files have been written. + +# There are users who deviate from the default file system layout. +# Check local settings to support them. +if [ -x %{_bindir}/my_print_defaults ] +then + mysql_datadir=`%{_bindir}/my_print_defaults server mysqld | grep '^--datadir=' | sed -n 's/--datadir=//p'` +fi +if [ -z "$mysql_datadir" ] +then + mysql_datadir=%{mysqldatadir} +fi + NEW_VERSION=%{mysql_version}-%{release} STATUS_FILE=$mysql_datadir/RPM_UPGRADE_MARKER @@ -1133,6 +1164,13 @@ fi ############################################################################## %changelog +* Thu Feb 03 2011 Joerg Bruehe + +- Fix bug#56581: If an installation deviates from the default file locations + ("datadir" and "pid-file"), the mechanism to detect a running server (on upgrade) + should still work, and use these locations. + The problem was that the fix for bug#27072 did not check for local settings. + * Wed Nov 24 2010 Alexander Nozdrin - EXCEPTIONS-CLIENT has been deleted, remove it from here too. From bdb4df0f266c7d7de794692f9579f4b1c8761ed1 Mon Sep 17 00:00:00 2001 From: "John H. Embretsen" Date: Wed, 9 Feb 2011 10:50:09 +0100 Subject: [PATCH 2/5] Backport to 5.0: Fix for Bug#52060 - test udf fails on Snow Leopard. Reverse DNS lookup of "localhost" returns "broadcasthost" on Snow Leopard (Mac), and NULL on most others. Simply ignore the output, as this is not an essential part of UDF testing. --- mysql-test/r/udf.result | 2 -- mysql-test/t/udf.test | 7 +++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/udf.result b/mysql-test/r/udf.result index 92185962d1f..27cd8e640f3 100644 --- a/mysql-test/r/udf.result +++ b/mysql-test/r/udf.result @@ -40,8 +40,6 @@ ERROR HY000: Wrong number of arguments to reverse_lookup; Use the source select reverse_lookup("127.0.0.1"); select reverse_lookup(127,0,0,1); select reverse_lookup("localhost"); -reverse_lookup("localhost") -NULL select avgcost(); ERROR HY000: wrong number of arguments: AVGCOST() requires two arguments select avgcost(100,23.76); diff --git a/mysql-test/t/udf.test b/mysql-test/t/udf.test index 648494b3df9..3633c77be0d 100644 --- a/mysql-test/t/udf.test +++ b/mysql-test/t/udf.test @@ -51,14 +51,17 @@ select lookup("localhost"); --error 0 select reverse_lookup(); -# These two functions should return "localhost", but it's +# These two function calls should return "localhost", but it's # depending on configuration, so just call them and don't log the result --disable_result_log select reverse_lookup("127.0.0.1"); select reverse_lookup(127,0,0,1); + +# This function call may return different results depending on platform, +# so ignore results (see Bug#52060). +select reverse_lookup("localhost"); --enable_result_log -select reverse_lookup("localhost"); --error 0 select avgcost(); --error 0 From 784e74235ae3c43bf5616198227412bc856d8bbc Mon Sep 17 00:00:00 2001 From: Dmitry Shulga Date: Wed, 9 Feb 2011 17:13:17 +0600 Subject: [PATCH 3/5] Follow up fix for bug#57450. batch_readline_init() was modified - make check for type of file for input stream unless target platform is WINDOWS since on this platform S_IFBLK is undefined. --- client/readline.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/readline.cc b/client/readline.cc index 9ac9ea5824e..fb8cde577b5 100644 --- a/client/readline.cc +++ b/client/readline.cc @@ -33,10 +33,12 @@ LINE_BUFFER *batch_readline_init(ulong max_size,FILE *file) LINE_BUFFER *line_buff; MY_STAT input_file_stat; +#ifndef __WIN__ if (my_fstat(fileno(file), &input_file_stat, MYF(MY_WME)) || MY_S_ISDIR(input_file_stat.st_mode) || MY_S_ISBLK(input_file_stat.st_mode)) return 0; +#endif if (!(line_buff=(LINE_BUFFER*) my_malloc(sizeof(*line_buff),MYF(MY_WME | MY_ZEROFILL)))) From b8d8d914fee8b992a7ecbd4d92e47803546efd53 Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Wed, 9 Feb 2011 16:25:34 +0100 Subject: [PATCH 4/5] Silly mistake in 59148, forgot .exe on Windows --- 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 a1e02a56164..5e61b4f1867 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -2022,7 +2022,7 @@ sub read_plugin_defs($) # Need to check if we will be running mysqld-debug if ($opt_debug_server) { - $running_debug= 1 if find_mysqld($basedir) =~ /-debug$/; + $running_debug= 1 if find_mysqld($basedir) =~ /mysqld-debug/; } while () { From e6ff7b63f9a2d4bff26dbfcbfb85c6aaa13a32a7 Mon Sep 17 00:00:00 2001 From: Jonathan Perkin Date: Wed, 9 Feb 2011 19:41:12 +0000 Subject: [PATCH 5/5] Combine test-bt and test-bt-debug into a single default.release collection, utilising the new --debug-server option for the debug run to ensure the correct binaries are used. Remove test-bt-*fast, they are unused. --- mysql-test/collections/default.release | 11 +++++++++++ mysql-test/collections/test-bt | 10 ---------- mysql-test/collections/test-bt-debug | 1 - mysql-test/collections/test-bt-debug-fast | 0 mysql-test/collections/test-bt-fast | 2 -- 5 files changed, 11 insertions(+), 13 deletions(-) create mode 100644 mysql-test/collections/default.release delete mode 100644 mysql-test/collections/test-bt delete mode 100644 mysql-test/collections/test-bt-debug delete mode 100644 mysql-test/collections/test-bt-debug-fast delete mode 100644 mysql-test/collections/test-bt-fast diff --git a/mysql-test/collections/default.release b/mysql-test/collections/default.release new file mode 100644 index 00000000000..108e1032ca2 --- /dev/null +++ b/mysql-test/collections/default.release @@ -0,0 +1,11 @@ +perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=debug --vardir=var-debug --skip-ndbcluster --skip-rpl --report-features --debug-server +perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=normal --vardir=var-normal --skip-ndbcluster --report-features +perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=ps --vardir=var-ps --skip-ndbcluster --ps-protocol +perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=funcs1+ps --vardir=var-funcs_1_ps --suite=funcs_1 --ps-protocol +perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=funcs2 --vardir=var-funcs2 --suite=funcs_2 +perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=partitions --vardir=var-parts --suite=parts +perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=stress --vardir=var-stress --suite=stress +perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=jp --vardir=var-jp --suite=jp +perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=embedded --vardir=var-embedded --embedded-server --skip-rpl --skip-ndbcluster +perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=nist --vardir=var-nist --suite=nist +perl mysql-test-run.pl --force --timer --parallel=auto --experimental=collections/default.experimental --comment=nist+ps --vardir=var-nist_ps --suite=nist --ps-protocol diff --git a/mysql-test/collections/test-bt b/mysql-test/collections/test-bt deleted file mode 100644 index 58f0c2c3cde..00000000000 --- a/mysql-test/collections/test-bt +++ /dev/null @@ -1,10 +0,0 @@ -perl mysql-test-run.pl --force --timer --parallel=auto --comment=normal --skip-ndbcluster --report-features --experimental=collections/default.experimental -perl mysql-test-run.pl --force --timer --parallel=auto --comment=ps --skip-ndbcluster --ps-protocol --experimental=collections/default.experimental -perl mysql-test-run.pl --force --timer --parallel=auto --comment=funcs1+ps --suite=funcs_1 --ps-protocol --experimental=collections/default.experimental -perl mysql-test-run.pl --force --timer --parallel=auto --comment=funcs2 --suite=funcs_2 --experimental=collections/default.experimental -perl mysql-test-run.pl --force --timer --parallel=auto --comment=partitions --suite=parts --experimental=collections/default.experimental -perl mysql-test-run.pl --force --timer --parallel=auto --comment=stress --suite=stress --experimental=collections/default.experimental -perl mysql-test-run.pl --force --timer --parallel=auto --comment=jp --suite=jp --experimental=collections/default.experimental -perl mysql-test-run.pl --force --timer --parallel=auto --comment=embedded --embedded-server --skip-rpl --skip-ndbcluster --experimental=collections/default.experimental -perl mysql-test-run.pl --force --timer --parallel=auto --comment=nist --suite=nist --experimental=collections/default.experimental -perl mysql-test-run.pl --force --timer --parallel=auto --comment=nist+ps --suite=nist --ps-protocol --experimental=collections/default.experimental diff --git a/mysql-test/collections/test-bt-debug b/mysql-test/collections/test-bt-debug deleted file mode 100644 index 5fc1e15e0d2..00000000000 --- a/mysql-test/collections/test-bt-debug +++ /dev/null @@ -1 +0,0 @@ -perl mysql-test-run.pl --force --timer --parallel=auto --comment=debug --skip-ndbcluster --skip-rpl --report-features --experimental=collections/default.experimental diff --git a/mysql-test/collections/test-bt-debug-fast b/mysql-test/collections/test-bt-debug-fast deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/mysql-test/collections/test-bt-fast b/mysql-test/collections/test-bt-fast deleted file mode 100644 index 7978c8082f0..00000000000 --- a/mysql-test/collections/test-bt-fast +++ /dev/null @@ -1,2 +0,0 @@ -perl mysql-test-run.pl --force --timer --parallel=auto --comment=ps --skip-ndbcluster --ps-protocol --report-features --experimental=collections/default.experimental -perl mysql-test-run.pl --force --timer --parallel=auto --comment=stress --suite=stress --experimental=collections/default.experimental