Re: FATAL: bogus data in lock file "postmaster.pid": ""

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Michael Beattie <mtbeedee(at)gmail(dot)com>
Cc: Magnus Hagander <magnus(at)hagander(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: FATAL: bogus data in lock file "postmaster.pid": ""
Date: 2012-08-27 04:02:13
Message-ID: 20120827040213.GF28780@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Jan 6, 2012 at 08:28:48AM -0500, Michael Beattie wrote:
> On Fri, Jan 6, 2012 at 6:13 AM, Magnus Hagander <magnus(at)hagander(dot)net> wrote:
>
> On Thu, Jan 5, 2012 at 23:19, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> > Magnus Hagander <magnus(at)hagander(dot)net> writes:
> >> On Thu, Jan 5, 2012 at 17:13, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> >>> I think link(2) would create race conditions of its own. I'd be
> >>> inclined to suggest that maybe we should just special-case a zero
> length
> >>> postmaster.pid file as meaning "okay to proceed". In general, garbage
> >
> >> That's pretty much what I meant - but with a warning message.
> >
> > Actually ... wait a minute. If we allow that, don't we create a race
> > condition between two postmasters starting at almost the same instant?
> > The second one could see the lock file when the first has created but
> > not yet filled it.
>
> Good point, yeah, it should do that. But I still think it's rare
> enough that just special-casing the error message should be enough...
>
>
>
> so just something that does like
>
> stat(filename, &st);
> size = st.st_size;
> if (size == 0)
> elog(ERROR, "lock file \"%s\" has 0 length.", filename);
>
> somewhere in CreateLockFile in miscinit.c?

I have developed the attached patch to report a zero-length file, as you
suggested.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +

Attachment Content-Type Size
pid.diff text/x-diff 534 bytes

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Albe Laurenz 2012-08-27 07:57:49 Re: [v9.3] writable foreign tables
Previous Message Tom Lane 2012-08-27 03:47:52 Re: Incorrect comment in fe-lobj.c