On Fri, Aug 3, 2012 at 11:59 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> 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.
> 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.
It strikes me that it would be sufficient to hold the fcntl() lock
just long enough to establish one of the other interlocks. We don't
really need to hold it for the entire lifetime of the postmaster.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company