Skip site navigation (1) Skip section navigation (2)

Re: [HACKERS] Fix PID file location?

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: josh(at)agliodbs(dot)com
Cc: PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: [HACKERS] Fix PID file location?
Date: 2005-05-27 21:25:50
Message-ID: 200505272125.j4RLPoE12563@candle.pha.pa.us (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-patches
I have generated the following patch that moves postmaster.pid into the
configuration directory.  pg_ctl only knows about the configuration
directory because it can't read postgresql.conf, so it seems that is the
right place to move it.

I have tested it and it seems to work. I would like to backpatch this to
8.0.X because it is currently broken without it.  This patch does
require that the postgres unix user have write permission in the
configuration directory to create the pid file on startup.

---------------------------------------------------------------------------

Josh Berkus wrote:
> Hey, folks,
> 
> I've noticed a problem with alternate PGDATA locations.  Here's how to 
> reproduce:
> 
> On 8.0.2 on RHAS4:
> 
> 1) Initdb a directory (on my system, /pgdata/pgdata)
> 2) Move the .conf files to an alternate location ( /etc/pgsql/)
> 3) Set $PGDATA to the alternate location ( /etc/pgsql )
> 4) Edit postgresql.conf to support this file arrangement
> 	data_directory = '/pgdata/pgdata'               
> 5) pg_ctl start PostgreSQL
> 6) pg_ctl stop PostgreSQL
> 7) Get an error:  "No PID file found".
> 
> The problem seems to be that pg_ctl expects the PID file to be in $PGDATA, but 
> the file actually gets written by the postmaster to the actual data 
> directory.  You can work around this by setting "external_pid_file", but this 
> then prevents you from using external_pid_file for another purpose.
> 
> Seems like it should be a relatively easy fix, although I'm not sure whether 
> the postmaster should write the PID to $PGDATA, or whether pg_ctl should be 
> made to look in the right place.  Probably the latter.

---------------------------------------------------------------------------

> More about this: due to the PID file not being in the right place, pg_ctl stop
> never reports success:
> 
> waiting for postmaster to shut
> down............................................................... failed
> pg_ctl: postmaster does not shut down
> 
> This appears to be because the duplicate PID in the conf directory is not
> removed on shutdown.


-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman(at)candle(dot)pha(dot)pa(dot)us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

In response to

Responses

pgsql-hackers by date

Next:From: Bruce MomjianDate: 2005-05-27 22:01:26
Subject: Re: Oracle Style packages on postgres
Previous:From: Bruce MomjianDate: 2005-05-27 20:37:59
Subject: Re: Cost of XLogInsert CRC calculations

pgsql-patches by date

Next:From: Bruce MomjianDate: 2005-05-27 22:09:57
Subject: Re: modified farsi faq in html and txt version
Previous:From: Robert TreatDate: 2005-05-27 21:14:57
Subject: Re: psql backslash consistency

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group