Re: CreateLockFile() race condition - Mailing list pgsql-hackers

From Noah Misch
Subject Re: CreateLockFile() race condition
Date
Msg-id 20120803175556.GF9683@tornado.leadboat.com
Whole thread Raw
In response to Re: CreateLockFile() race condition  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Fri, Aug 03, 2012 at 11:59:00AM -0400, Tom Lane wrote:
> Noah Misch <noah@leadboat.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


pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: -Wformat-zero-length
Next
From: Tom Lane
Date:
Subject: Re: Re: SPGiST versus hot standby - question about conflict resolution rules