From owner-freebsd-ports-bugs@FreeBSD.ORG Sun Aug 11 17:20:02 2013 Return-Path: Delivered-To: freebsd-ports-bugs@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 7DB49F27 for ; Sun, 11 Aug 2013 17:20:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 5CAA42E0E for ; Sun, 11 Aug 2013 17:20:02 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.7/8.14.7) with ESMTP id r7BHK2Oe054473 for ; Sun, 11 Aug 2013 17:20:02 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.7/8.14.7/Submit) id r7BHK2sA054472; Sun, 11 Aug 2013 17:20:02 GMT (envelope-from gnats) Resent-Date: Sun, 11 Aug 2013 17:20:02 GMT Resent-Message-Id: <201308111720.r7BHK2sA054472@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, Volodymyr Kostyrko Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 54781DE0 for ; Sun, 11 Aug 2013 17:10:31 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from oldred.freebsd.org (oldred.freebsd.org [8.8.178.121]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 42F8A2DD3 for ; Sun, 11 Aug 2013 17:10:31 +0000 (UTC) Received: from oldred.freebsd.org ([127.0.1.6]) by oldred.freebsd.org (8.14.5/8.14.7) with ESMTP id r7BHAVXp031754 for ; Sun, 11 Aug 2013 17:10:31 GMT (envelope-from nobody@oldred.freebsd.org) Received: (from nobody@localhost) by oldred.freebsd.org (8.14.5/8.14.5/Submit) id r7BHAUhg031727; Sun, 11 Aug 2013 17:10:30 GMT (envelope-from nobody) Message-Id: <201308111710.r7BHAUhg031727@oldred.freebsd.org> Date: Sun, 11 Aug 2013 17:10:30 GMT From: Volodymyr Kostyrko To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Subject: ports/181228: databases/postgresql rc.d script fails to start server X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 11 Aug 2013 17:20:02 -0000 >Number: 181228 >Category: ports >Synopsis: databases/postgresql rc.d script fails to start server >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sun Aug 11 17:20:02 UTC 2013 >Closed-Date: >Last-Modified: >Originator: Volodymyr Kostyrko >Release: RELENG-9.1 >Organization: none >Environment: FreeBSD kohrah.xim.bz 9.1-RELEASE-p4 FreeBSD 9.1-RELEASE-p4 #2 r252247M: Wed Jun 26 11:59:47 EEST 2013 arcade@kohrah.xim.bz:/usr/obj/usr/src/sys/MINIMAL amd64 >Description: Sometimes server crashes leaving some files behind. Then when everything boots postgresql says that server is already running. As postgresql rc.d script doesn't specify a way to handle pid files all file handling is through pg_ctl. Here's a snip from an IRC log: [16:53] on my system pids are given out in numerical order at boot, so if machine crashes the pid that was used for the server last time can already be present, but occupied by other process [16:53] does pg_ctl check that this pid belongs to pgsql user or is a server? [16:54] it only considers it to be "running" if it is allowed to send signals to it [16:54] since pg_ctl is supposed to be run as the postgres user, not root, that should suffice [16:55] also it checks that it's not the pg_ctl pid itself or its parent shell [16:55] there is still one possible failure mode [16:55] which is that if you do su postgres -c "somecomplexscript" which eventually gets to pg_ctl after more than one fork, [16:56] it's possible for one of the grandparent processes of pg_ctl to be mistaken for the postmaster I'm not sure how pg_ctl checks this but can someone confirm or deny such claim? >How-To-Repeat: >Fix: >Release-Note: >Audit-Trail: >Unformatted: