pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: xsun <xu2002261@163.com>
Cc: pgsql-admin@postgresql.org
Subject: Re: The function of lock file named ".s.PGSQL.<port>.lock" on Linux?
Date: Thu, 05 Aug 2010 12:41:14 -0400
Message-ID: <16464.1281026474@sss.pgh.pa.us> (raw)
In-Reply-To: <i399mq$28vn$1@news.hub.org>
References: <i399mq$28vn$1@news.hub.org>

"xsun" <xu2002261@163.com> writes:
> When the psql server is started under Linux platform, in /tmp directory 
> there is a lock files named ".s.PGSQL.<port>.lock". So I want to know what 
> is the function of this lock file?

It prevents multiple postmasters from trying to use the same socket file.

> And does the server work well without 
> this lock file?

No.  (Well, it will run, but you have no protection against accidentally
starting another postmaster on the same port number.)

> Additionally, I know that the file ".s.PGSQL.<port>" is used as the unix 
> domain socket file. But the file ".s.PGSQL.<port>.lock" makes me still 
> pazzled. Could you explain that? Thanks.

We can't portably lock the socket file itself, so we make a separate
ordinary file for locking purposes.

			regards, tom lane



view thread (6+ messages)  latest in thread

Message-ID: <16464.1281026474@sss.pgh.pa.us>
Permalink:  ../16464.1281026474@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/16464.1281026474@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: tgl@sss.pgh.pa.us, xu2002261@163.com
  Subject: Re: The function of lock file named ".s.PGSQL.<port>.lock" on Linux?
  In-Reply-To: <16464.1281026474@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox