Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 6531E632EF8 for ; Tue, 10 Aug 2010 22:10:26 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 17286-08 for ; Wed, 11 Aug 2010 01:10:13 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 1D023632C8C for ; Tue, 10 Aug 2010 22:10:15 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id o7B19tsn023169; Tue, 10 Aug 2010 21:09:56 -0400 (EDT) To: Greg Smith cc: xsun , pgsql-admin@postgresql.org Subject: Re: The function of lock file named ".s.PGSQL..lock" on Linux? In-reply-to: <4C61F3FF.1080303@2ndquadrant.com> References: <16464.1281026474@sss.pgh.pa.us> <4C61F3FF.1080303@2ndquadrant.com> Comments: In-reply-to Greg Smith message dated "Tue, 10 Aug 2010 20:51:11 -0400" Date: Tue, 10 Aug 2010 21:09:55 -0400 Message-ID: <23168.1281488995@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201008/82 X-Sequence-Number: 35331 Greg Smith 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