Обсуждение: Stopping Postgres

Поиск
Список
Период
Сортировка

Stopping Postgres

От
David Mitchell
Дата:
What is the best way to quickly and reliably stop postgres? We've found
that pg_ctl doesn't work for us very well, frequently failing to
actually stop the postmaster (it times out and reports that it has
failed to stop). This is the same even if we use -m immediate.

We don't want to kill -9, obviously. How do other people ensure that
postgres is properly stopped in a timely manner?

Regards
--
David Mitchell
Software Engineer
Telogis

Re: Stopping Postgres

От
Richard Huxton
Дата:
David Mitchell wrote:
> What is the best way to quickly and reliably stop postgres? We've found
> that pg_ctl doesn't work for us very well, frequently failing to
> actually stop the postmaster (it times out and reports that it has
> failed to stop). This is the same even if we use -m immediate.

AFAIK pg_ctl just signals the backend (as you can do with kill). Are you
saying it never exits, or just that pg_ctl stops waiting for it to finish?

--
   Richard Huxton
   Archonet Ltd

Re: Stopping Postgres

От
Tom Lane
Дата:
David Mitchell <david.mitchell@telogis.com> writes:
> What is the best way to quickly and reliably stop postgres? We've found
> that pg_ctl doesn't work for us very well, frequently failing to
> actually stop the postmaster (it times out and reports that it has
> failed to stop). This is the same even if we use -m immediate.

pg_ctl always works for me (and I use it several times a day ;-)).
What PG version are you using, on what platform?  Is it possible
you've got permissions problems?

            regards, tom lane

Re: Stopping Postgres

От
David Mitchell
Дата:
I'm using PG 8.0.1 on Gentoo Linux (kernel 2.6.10 SMP) on Pentium 4 w/ HT.

I run the following as root:

su postgres -c "pg_ctl stop -D /var/lib/postgresql/data -m fast"

Or with -m immediate. Some of the backends stop but others never
shutdown. Even if I do a killall postmaster (just with sigterm, not -9),
these backends hang around. The backends are currently executing queries
but the queries stop running at this point.

I'm not starting the server with pg_ctl, I run postmaster by hand.
Perhaps there is something in my init script that is to blame.

Cheers
David

Tom Lane wrote:
> David Mitchell <david.mitchell@telogis.com> writes:
>
>>What is the best way to quickly and reliably stop postgres? We've found
>>that pg_ctl doesn't work for us very well, frequently failing to
>>actually stop the postmaster (it times out and reports that it has
>>failed to stop). This is the same even if we use -m immediate.
>
>
> pg_ctl always works for me (and I use it several times a day ;-)).
> What PG version are you using, on what platform?  Is it possible
> you've got permissions problems?
>
>             regards, tom lane
>
>


--
David Mitchell
Software Engineer
Telogis

Re: Stopping Postgres

От
Tom Lane
Дата:
David Mitchell <david.mitchell@telogis.com> writes:
> I run the following as root:
> su postgres -c "pg_ctl stop -D /var/lib/postgresql/data -m fast"
> Or with -m immediate. Some of the backends stop but others never
> shutdown. Even if I do a killall postmaster (just with sigterm, not -9),
> these backends hang around. The backends are currently executing queries
> but the queries stop running at this point.

Can you be more specific about what queries the problem backends are
executing?  It sounds to me like a situation where those backends are
executing a code path that doesn't do CHECK_FOR_INTERRUPTS reasonably
often.  We find such paths every now and then, but it's hard to guess
exactly where your difficulty might be without more data.

The very best thing would be to attach to some of the non-stopping
backends with gdb and get stack traces.

            regards, tom lane