Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 11 Aug 2013 17:10:30 GMT
From:      Volodymyr Kostyrko <c.kworr@gmail.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   ports/181228: databases/postgresql rc.d script fails to start server
Message-ID:  <201308111710.r7BHAUhg031727@oldred.freebsd.org>
Resent-Message-ID: <201308111720.r7BHK2sA054472@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>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] <arcade_> 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] <arcade_> does pg_ctl check that this pid belongs to pgsql user or is a server?
[16:54] <RhodiumToad> it only considers it to be "running" if it is allowed to send signals to it
[16:54] <RhodiumToad> since pg_ctl is supposed to be run as the postgres user, not root, that should suffice
[16:55] <RhodiumToad> also it checks that it's not the pg_ctl pid itself or its parent shell
[16:55] <RhodiumToad> there is still one possible failure mode
[16:55] <RhodiumToad> which is that if you do  su postgres -c "somecomplexscript"  which eventually gets to pg_ctl after more than one fork,
[16:56] <RhodiumToad> 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:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201308111710.r7BHAUhg031727>