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: "xsun" <xu2002261(at)163(dot)com>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: The function of lock file named ".s.PGSQL.<port>.lock" on Linux?
Date: 2010-08-05 16:41:14
Message-ID: 16464.1281026474@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

"xsun" <xu2002261(at)163(dot)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

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Bob Lunney 2010-08-05 17:39:53 Re: out of memory error
Previous Message Scott Marlowe 2010-08-05 16:13:41 Re: out of memory error