pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
The function of lock file named ".s.PGSQL.<port>.lock" on Linux?
6+ messages / 3 participants
[nested] [flat]

* The function of lock file named ".s.PGSQL.<port>.lock" on Linux?
@ 2010-08-03 14:39 xsun <xu2002261@163.com>
  2010-08-05 16:41 ` Re: The function of lock file named ".s.PGSQL.<port>.lock" on Linux? Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 6+ messages in thread

From: xsun @ 2010-08-03 14:39 UTC (permalink / raw)
  To: pgsql-admin

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? And does the server work well without 
this lock file?

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.


Best wishes. 





^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: The function of lock file named ".s.PGSQL.<port>.lock" on Linux?
  2010-08-03 14:39 The function of lock file named ".s.PGSQL.<port>.lock" on Linux? xsun <xu2002261@163.com>
@ 2010-08-05 16:41 ` Tom Lane <tgl@sss.pgh.pa.us>
  2010-08-11 00:51   ` Re: The function of lock file named ".s.PGSQL.<port>.lock" on Linux? Greg Smith <greg@2ndquadrant.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Tom Lane @ 2010-08-05 16:41 UTC (permalink / raw)
  To: xsun <xu2002261@163.com>; +Cc: pgsql-admin

"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



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: The function of lock file named ".s.PGSQL.<port>.lock" on Linux?
  2010-08-03 14:39 The function of lock file named ".s.PGSQL.<port>.lock" on Linux? xsun <xu2002261@163.com>
  2010-08-05 16:41 ` Re: The function of lock file named ".s.PGSQL.<port>.lock" on Linux? Tom Lane <tgl@sss.pgh.pa.us>
@ 2010-08-11 00:51   ` Greg Smith <greg@2ndquadrant.com>
  2010-08-11 01:09     ` Re: The function of lock file named ".s.PGSQL.<port>.lock" on Linux? Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 6+ messages in thread

From: Greg Smith @ 2010-08-11 00:51 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: xsun <xu2002261@163.com>; pgsql-admin

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?

-- 
Greg Smith  2ndQuadrant US  Baltimore, MD
PostgreSQL Training, Services and Support
greg@2ndQuadrant.com   www.2ndQuadrant.us




^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: The function of lock file named ".s.PGSQL.<port>.lock" on Linux?
  2010-08-03 14:39 The function of lock file named ".s.PGSQL.<port>.lock" on Linux? xsun <xu2002261@163.com>
  2010-08-05 16:41 ` Re: The function of lock file named ".s.PGSQL.<port>.lock" on Linux? Tom Lane <tgl@sss.pgh.pa.us>
  2010-08-11 00:51   ` Re: The function of lock file named ".s.PGSQL.<port>.lock" on Linux? Greg Smith <greg@2ndquadrant.com>
@ 2010-08-11 01:09     ` Tom Lane <tgl@sss.pgh.pa.us>
  2010-08-26 22:01       ` Re: The function of lock file named ".s.PGSQL.<port>.lock" on Linux? Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 6+ messages in thread

From: Tom Lane @ 2010-08-11 01:09 UTC (permalink / raw)
  To: Greg Smith <greg@2ndquadrant.com>; +Cc: xsun <xu2002261@163.com>; pgsql-admin

Greg Smith <greg@2ndquadrant.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



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: The function of lock file named ".s.PGSQL.<port>.lock" on Linux?
  2010-08-03 14:39 The function of lock file named ".s.PGSQL.<port>.lock" on Linux? xsun <xu2002261@163.com>
  2010-08-05 16:41 ` Re: The function of lock file named ".s.PGSQL.<port>.lock" on Linux? Tom Lane <tgl@sss.pgh.pa.us>
  2010-08-11 00:51   ` Re: The function of lock file named ".s.PGSQL.<port>.lock" on Linux? Greg Smith <greg@2ndquadrant.com>
  2010-08-11 01:09     ` Re: The function of lock file named ".s.PGSQL.<port>.lock" on Linux? Tom Lane <tgl@sss.pgh.pa.us>
@ 2010-08-26 22:01       ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2010-08-26 22:01 UTC (permalink / raw)
  To: Greg Smith <greg@2ndquadrant.com>; xsun <xu2002261@163.com>; pgsql-admin

Greg Smith <greg@2ndquadrant.com> writes:
>> 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?

Done.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* The function of lock file named ".s.PGSQL.<port>.lock" on Linux?
@ 2010-08-03 14:46 xsun <xu2002261@163.com>
  0 siblings, 0 replies; 6+ messages in thread

From: xsun @ 2010-08-03 14:46 UTC (permalink / raw)
  To: pgsql-admin

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? And does the server work well without
this lock file?

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.


Best wishes.







^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2010-08-26 22:01 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2010-08-03 14:39 The function of lock file named ".s.PGSQL.<port>.lock" on Linux? xsun <xu2002261@163.com>
2010-08-05 16:41 ` Tom Lane <tgl@sss.pgh.pa.us>
2010-08-11 00:51   ` Greg Smith <greg@2ndquadrant.com>
2010-08-11 01:09     ` Tom Lane <tgl@sss.pgh.pa.us>
2010-08-26 22:01       ` Tom Lane <tgl@sss.pgh.pa.us>
2010-08-03 14:46 The function of lock file named ".s.PGSQL.<port>.lock" on Linux? xsun <xu2002261@163.com>

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