Re: CreateLockFile() race condition

From: Noah Misch <noah(at)leadboat(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: CreateLockFile() race condition
Date: 2012-08-03 17:55:56
Message-ID: 20120803175556.GF9683@tornado.leadboat.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Aug 03, 2012 at 11:59:00AM -0400, Tom Lane wrote:
> Noah Misch <noah(at)leadboat(dot)com> writes:
> > I think we should instead implement postmaster mutual exclusion by way of
> > fcntl(F_SETLK) on Unix and CreateFile(..., FILE_SHARE_READ, ...) on Windows.
>
> I'm a bit worried about what new problems this solution is going to open
> up. It seems not unlikely that the cure is worse than the disease.

That's a fair concern. There's only so much we'll know in advance.

> Having locking that actually works on (some) NFS setups would be nice,
> but ...
>
> > The hazard[4] keeping fcntl locking from replacing the PGSharedMemoryIsInUse()
> > check does not apply here, because the postmaster itself does not run
> > arbitrary code that might reopen postmaster.pid.
>
> False. See shared_preload_libraries.

Quite right. Even so, that code has a special role and narrower goals to
which it can reasonable aspire, giving credibility to ignoring the problem or
documenting the problem away. (I don't see that we document any of the other
constraints on _PG_init of libraries named in shared_preload_libraries.)

Thanks,
nm

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2012-08-03 18:02:35 Re: Re: SPGiST versus hot standby - question about conflict resolution rules
Previous Message Bruce Momjian 2012-08-03 17:32:21 Re: -Wformat-zero-length