From owner-freebsd-ports-bugs@FreeBSD.ORG Tue Mar 25 04:40:03 2008 Return-Path: Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AF5441065674 for ; Tue, 25 Mar 2008 04:40:03 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 753698FC19 for ; Tue, 25 Mar 2008 04:40:03 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.2/8.14.2) with ESMTP id m2P4e30s088478 for ; Tue, 25 Mar 2008 04:40:03 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.2/8.14.1/Submit) id m2P4e3kn088477; Tue, 25 Mar 2008 04:40:03 GMT (envelope-from gnats) Resent-Date: Tue, 25 Mar 2008 04:40:03 GMT Resent-Message-Id: <200803250440.m2P4e3kn088477@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Christopher Sean Hilton Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3242B106564A for ; Tue, 25 Mar 2008 04:35:16 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id 0A1BC8FC24 for ; Tue, 25 Mar 2008 04:35:16 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.2/8.14.2) with ESMTP id m2P4Z4WR002150 for ; Tue, 25 Mar 2008 04:35:04 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.2/8.14.1/Submit) id m2P4Z4jZ002149; Tue, 25 Mar 2008 04:35:04 GMT (envelope-from nobody) Message-Id: <200803250435.m2P4Z4jZ002149@www.freebsd.org> Date: Tue, 25 Mar 2008 04:35:04 GMT From: Christopher Sean Hilton To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: ports/122063: Mysql-server rc.d script finishes before mysqld has established listening socket. X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Mar 2008 04:40:03 -0000 >Number: 122063 >Category: ports >Synopsis: Mysql-server rc.d script finishes before mysqld has established listening socket. >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Tue Mar 25 04:40:03 UTC 2008 >Closed-Date: >Last-Modified: >Originator: Christopher Sean Hilton >Release: 6.1-STABLE >Organization: >Environment: FreeBSD corellia.vindaloo.com 6.1-RELEASE FreeBSD 6.1-RELEASE #0: Thu Jun 1 22:42:32 EDT 2006 chris@corellia2:/usr/src/sys/i386/compile/CORELLIA i386 >Description: The rc.d script shipped with the port of mysql server exits immediately after mysqld starts. This normally wouldn't be a problem but the mysql daemon exits about a second before it has established it's unix domain listening socket: "/tmp/mysql". The problem here is that the rc startup system can queue the next daemon to start before "/tmp/mysql" is available. If the next daemon needs mysql it will fail and exit. On my system rcorder starts mysql-server and then immediately follows up with jabberd. Since mysql doesn't appear ready for about a second jabberd fails and exits. I've attached a patch which waits for up to 15 seconds for the /tmp/mysql socket to appear in the filesystem and exits as soon as it's available. This allows the next daemon in line to startup properly if it needs mysql. Note that I have had this problem with postfix up until I removed my mail information from mysql. >How-To-Repeat: Build a system that uses mysql and jabber or postfix. Ensure that jabberd starts after mysql by hacking /usr/local/etc/rc.d/jabberd's ## REQUIRES line. Assuming you're not on some hot rod of a machine check your logs for jabberd2's failure line in the service manager. >Fix: This may not adhere to the strictest rules of the rcorder system but my solution is to hack the provider's (mysql-server) startup script. The goal was to prevent the script from exiting until either the listening socket is established or a 15 second timeout has passed. A better solution would be for mysqld to establish the listening socket first (even if it ignores incoming connections for a little bit) but that's much higher effort. Patch attached with submission follows: --- mysql-server.sh.in 2008-03-25 00:10:14.000000000 -0400 +++ mysql-server.sh.in.orig 2008-03-25 00:02:58.000000000 -0400 @@ -18,8 +18,6 @@ # Base database directory. # mysql_args (str): Custom additional arguments to be passed # to mysqld_safe (default empty). -# mysql_conn_socket (str): Defaults to "/tmp/mysql.sock" -# The unix domain socket the daemon listens on. # . %%RC_SUBR%% @@ -32,17 +30,15 @@ : ${mysql_enable="NO"} : ${mysql_limits="NO"} : ${mysql_dbdir="/var/db/mysql"} -: ${mysql_conn_socket="/tmp/mysql.sock"} : ${mysql_args=""} mysql_user="mysql" mysql_limits_args="-e -U ${mysql_user}" pidfile="${mysql_dbdir}/`/bin/hostname`.pid" command="%%PREFIX%%/bin/mysqld_safe" -command_args="--defaults-extra-file=${mysql_dbdir}/my.cnf --user=${mysql_user} --datadir=${mysql_dbdir} --pid-file=${pidfile} ${mysql_args}" +command_args="--defaults-extra-file=${mysql_dbdir}/my.cnf --user=${mysql_user} --datadir=${mysql_dbdir} --pid-file=${pidfile} ${mysql_args} > /dev/null &" procname="%%PREFIX%%/libexec/mysqld" start_precmd="${name}_prestart" -start_cmd="${name}_start" mysql_install_db="%%PREFIX%%/bin/mysql_install_db" mysql_install_db_args="--ldata=${mysql_dbdir}" @@ -64,19 +60,4 @@ fi } -mysql_start() -{ - local timeout=15 - - echo "Starting ${name}" - - ${command} ${command_args} < /dev/null > /dev/null 2>&1 & - while [ ! -S "${mysql_conn_socket}" -a ${timeout} -gt 0 ]; do - timeout=$(( timeout - 1 )) - sleep 1 - done - - return 0 -} - run_rc_command "$1" >Release-Note: >Audit-Trail: >Unformatted: