Re: Postgresql goes down need to restart (redhat postgresql service script) lock files removal avoid 2 postmasters

From: mlaks <mlaks(at)bellatlantic(dot)net>
To: pgsql-admin(at)postgresql(dot)org
Cc: Bruno Wolff III <bruno(at)wolff(dot)to>
Subject: Re: Postgresql goes down need to restart (redhat postgresql service script) lock files removal avoid 2 postmasters
Date: 2003-05-08 18:10:52
Message-ID: 200305081410.52791.mlaks@bellatlantic.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Thank you for your response Bruno. I agree about the importance of using the
lines

#!/bin/sh
exec 2>&1
exec setuidgid postgres /usr/local/pgsql/bin/postmaster -D
/usr/local/pgsql/data

in the run file. However, what else must we put in as well?

My question is to understand the lock files for postgresql so I can deal with
the following:

1.

I notice that Lamar's postgresql service script removes "stale lock files"
before starting postgresql by using the line

rm -f /tmp/.s.PGSQL.* > /dev/null

and perhaps my own experience indicates we also should add a line

rm -f /var/lib/pgsql/data/postmaster.pid

because sometimes when my machine crashes and gets rebooted I must manually
remove that file.

2.

Moreover, I see that after successfully starting postgresql Lamar touches a
file

touch /var/lock/subsys/postgresql

and does this

echo $pid > /var/run/postmaster.pid

so how can we do that?

3.

I can imagine we can accomplish 1. with

#!/bin/sh
rm -f /tmp/.s.PGSQL.* > /dev/null
rm -f /var/lib/pgsql/data/postmaster.pid
exec 2>&1
exec setuidgid postgres /usr/local/pgsql/bin/postmaster -D
/usr/local/pgsql/data

but how do we do 2. -> the touching and echoing after the process starts if we
have replaced the "run" process by the postmaster process with the exec so
that the daemontools "svc" can control the process?

Mitchell

On Thursday 08 May 2003 01:50 pm, you wrote:
> On Thu, May 08, 2003 at 12:50:49 -0400,
>
> mlaks <mlaks(at)bellatlantic(dot)net> wrote:
> > My goal is to use DJ Bernsteins daemonstools to make sure that my
> > Postgresql process goes back up unattended if it goes down for some
> > reason. So I will be substituting daemontools for the postgresql service
> > script.
> > Thus I want to know what lock files to remove to make sure all is ok. I
> > also want to follow Tom Lanes's advice and not shoot myself in the foot
> > by creating two different postmaster processes working the same
> > database!!!!
>
> This is what I put in my run file:
> #!/bin/sh
> exec 2>&1
> exec setuidgid postgres /usr/local/pgsql/bin/postmaster -D
> /usr/local/pgsql/data
>
> I use multilog for logging as you normally would.

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message mlaks 2003-05-08 18:39:08 Re: Postgresql goes down need to restart (redhat postgresql service script) lock files removal avoid 2 postmasters
Previous Message Andrew Sullivan 2003-05-08 18:05:24 Re: The database system is in recovery mode