Re: How to implement autostart of postgres? - Mailing list pgsql-general

From Tom Lane
Subject Re: How to implement autostart of postgres?
Date
Msg-id 24379.1311948082@sss.pgh.pa.us
Whole thread Raw
In response to Re: How to implement autostart of postgres?  (Craig Ringer <craig@postnewspapers.com.au>)
List pgsql-general
Craig Ringer <craig@postnewspapers.com.au> writes:
> On 28/07/11 18:06, Gavrina, Irina wrote:
>> Is there any risk of losing of data or data corruption in this case?

> Possibly, if you then remove postmaster.pid, thus bypassing the other
> safety, and start a new postmaster.

> I'm a bit alarmed to discover that Ubuntu's postgresql packaging appears
> to do exactly this.
> ...
> It merrily removes the pid file without any effort to check if there are
> backends using that datadir, then goes on to relaunch the postmaster.

> Is this sane? Safe?

No, and no.  The postmaster is capable of removing the old pidfile if it
really is stale, and any scripted substitute for that is highly likely
to be unsafe.  You do have to be a bit careful about how you code the
script though, to ensure that the postmaster won't see false positives.
Martin, is that code your responsibility?

            regards, tom lane

pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: repmgr and archive_mode
Next
From: Peter Eisentraut
Date:
Subject: Re: query_to_xml nulls set to false