From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.sysutils.supervision.general/761 Path: news.gmane.org!not-for-mail From: Charlie Brady Newsgroups: gmane.comp.sysutils.supervision.general Subject: Warning about mysqld's behaviour Date: Sun, 10 Apr 2005 23:16:06 -0400 (EDT) Message-ID: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Trace: sea.gmane.org 1113189208 29853 80.91.229.2 (11 Apr 2005 03:13:28 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 11 Apr 2005 03:13:28 +0000 (UTC) Original-X-From: supervision-return-997-gcsg-supervision=m.gmane.org@list.skarnet.org Mon Apr 11 05:13:26 2005 Return-path: Original-Received: from antah.skarnet.org ([212.85.147.14]) by ciao.gmane.org with smtp (Exim 4.43) id 1DKpMW-0000A3-H6 for gcsg-supervision@gmane.org; Mon, 11 Apr 2005 05:13:20 +0200 Original-Received: (qmail 10981 invoked by uid 76); 11 Apr 2005 03:16:32 -0000 Mailing-List: contact supervision-help@list.skarnet.org; run by ezmlm List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Archive: Original-Received: (qmail 10975 invoked from network); 11 Apr 2005 03:16:32 -0000 X-X-Sender: charlieb@e-smith.charlieb.ott.istop.com Original-To: supervision@list.skarnet.org Xref: news.gmane.org gmane.comp.sysutils.supervision.general:761 X-Report-Spam: http://spam.gmane.org/gmane.comp.sysutils.supervision.general:761 Version of mysql is 3.23.58. I haven't looked at other versions, so don't know whether this is new or old brain-damage. I have a straightforward run file: #!/bin/sh exec /usr/libexec/mysqld \ --defaults-file=/etc/my.cnf \ --basedir=/usr \ --datadir=/var/lib/mysql \ --user=mysql \ --pid-file=/var/run/mysqld/mysqld.pid This starts a set of four mysqld processes/threads: ... 492 ? S 0:00 \_ supervise mysqld 31796 ? S 0:00 | \_ /usr/libexec/mysqld --defaults-file=/etc/my.cnf --basedir=/usr --datadir=/var/lib/mysql -- 31797 ? S 0:00 | \_ /usr/libexec/mysqld --defaults-file=/etc/my.cnf --basedir=/usr --datadir=/var/lib/mysq 31798 ? S 0:00 | \_ /usr/libexec/mysqld --defaults-file=/etc/my.cnf --basedir=/usr --datadir=/var/lib/ 31800 ? S 0:00 | \_ /usr/libexec/mysqld --defaults-file=/etc/my.cnf --basedir=/usr --datadir=/var/lib/ 493 ? S 0:00 \_ supervise log ... But notice that the pid file doesn't reference the parent process: sh-2.05a# svstat . .: up (pid 31796) 123 seconds, normally down sh-2.05a# sh-2.05a# cat /var/run/mysqld/mysqld.pid ; echo 31798 sh-2.05a# But, it's worse than that, Jim! The parent process - the one that supervise is watching and "controlling" ignores INT, TERM and QUIT signals. sh-2.05a# kill -TERM 31796 sh-2.05a# svstat . .: up (pid 31796) 309 seconds, normally down sh-2.05a# kill -QUIT 31796 sh-2.05a# svstat . .: up (pid 31796) 321 seconds, normally down sh-2.05a# kill -INT 31796 sh-2.05a# svstat . .: up (pid 31796) 327 seconds, normally down sh-2.05a# So we lose control of the daemon: sh-2.05a# svc -t . sh-2.05a# svstat . .: up (pid 31796) 417 seconds, normally down sh-2.05a# Fortunately runit provides an easy solution to this problem (although we are left with no option but to trust a pid file, with all the problems that entails). We just create control/t and control/d files (at least), containing: #! /bin/sh exec kill -TERM $(cat /var/run/mysqld/mysqld.pid) Without this feature from runit, we need to do something like this to run mysqld under supervise: trap 'read pid