Re: Shutting down server from a backend process, e.g. walrceiver

From: fazool mein <fazoolmein(at)gmail(dot)com>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Shutting down server from a backend process, e.g. walrceiver
Date: 2010-09-21 17:50:56
Message-ID: AANLkTimF+H78eLWUM0uH64WSja5OzYH7gBbkC-ZE_15G@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Sep 20, 2010 at 9:44 PM, Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:

> On Tue, Sep 21, 2010 at 9:48 AM, fazool mein <fazoolmein(at)gmail(dot)com> wrote:
> > Hi,
> >
> > I want to shut down the server under certain conditions that can be
> checked
> > inside a backend process. For instance, while running symmetric
> replication,
> > if the primary dies, I want the the walreceiver to detect that and
> shutdown
> > the standby. The reason for shutdown is that I want to execute some other
> > stuff before I start the standby as a primary. Creating a trigger file
> > doesn't help as it converts the standby into primary at run time.
> >
> > Using proc_exit() inside walreceiver only terminates the walreceiver
> > process, which postgres starts again. The other way I see is using
> > ereport(PANIC, ...). Is there some other way to shutdown the main server
> > from within a backend process?
>
> Are you going to change the source code? If yes, you might be able to
> do that by making walreceiver send the shutdown signal to postmaster.
>
>
Yes, I'll be modifying the code. In the walreceiver, I used the following to
send a shutdown to the postmaster:

kill(getppid(), SIGTERM);

> If no, I think that a straightforward approach is to use a clusterware
> like pacemaker. That is, you need to make a clusterware periodically
> check the master and cause the standby to end when detecting the crash
> of the master.
>
>
This was another option, but I have to modify the code for this particular
case.

Thanks for your help.

Regards,

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message fazool mein 2010-09-21 17:53:24 Re: Shutting down server from a backend process, e.g. walrceiver
Previous Message Tom Lane 2010-09-21 17:46:33 Re: .gitignore files, take two