Re: The function of lock file named ".s.PGSQL.<port>.lock" on Linux?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Greg Smith <greg(at)2ndquadrant(dot)com>
Cc: xsun <xu2002261(at)163(dot)com>, pgsql-admin(at)postgresql(dot)org
Subject: Re: The function of lock file named ".s.PGSQL.<port>.lock" on Linux?
Date: 2010-08-11 01:09:55
Message-ID: 23168.1281488995@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Greg Smith <greg(at)2ndquadrant(dot)com> writes:
> Tom Lane wrote:
>> We can't portably lock the socket file itself, so we make a separate
>> ordinary file for locking purposes.

> It looks to me like the fact that the .lock file is created is only
> documented in src/backend/utils/init/miscinit.c , and even there the
> reason why (what you wrote above) isn't mentioned. Seems like noting
> this file is created in the unix_socket_directory entry of the docs, and
> the rationale for why in the source code, would make a useful
> improvement. Anybody want to write a little documentation patch?

FWIW, the discussion about that was here:
http://archives.postgresql.org/pgsql-hackers/2000-11/msg01306.php

and the subsequent commit was

2000-11-29 15:59 tgl

* configure, configure.in, src/backend/libpq/pqcomm.c,
src/backend/postmaster/postmaster.c, src/backend/tcop/postgres.c,
src/backend/utils/init/miscinit.c, src/backend/utils/misc/guc.c,
src/bin/pg_ctl/pg_ctl.sh, src/include/config.h.in,
src/include/miscadmin.h: Get rid of not-very-portable
fcntl(F_SETLK) mechanism for locking the Unix socket file, in favor
of having an ordinary lockfile beside the socket file. Clean up a
few robustness problems in the lockfile code. If postmaster is
going to reject a connection request based on database state, it
will now tell you so before authentication exchange not after. (Of
course, a failure after is still possible if conditions change
meanwhile, but this makes life easier for a yet-to-be-written
pg_ping utility.)

(The pgsql-committers messages were pretty useless back then, so I won't
point you to that archive.)

regards, tom lane

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Gnanakumar 2010-08-11 05:07:08 Autovacuum daemon internal handling
Previous Message Greg Smith 2010-08-11 00:51:11 Re: The function of lock file named ".s.PGSQL.<port>.lock" on Linux?