Re: Autovacuum worker doesn't immediately exit on postmaster death - Mailing list pgsql-hackers

From Stephen Frost
Subject Re: Autovacuum worker doesn't immediately exit on postmaster death
Date
Msg-id 20201029160832.GM16415@tamriel.snowman.net
Whole thread Raw
In response to Re: Autovacuum worker doesn't immediately exit on postmaster death  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Autovacuum worker doesn't immediately exit on postmaster death
Re: Autovacuum worker doesn't immediately exit on postmaster death
List pgsql-hackers
Greetings,

* Tom Lane (tgl@sss.pgh.pa.us) wrote:
> Victor Yegorov <vyegorov@gmail.com> writes:
> > ср, 28 окт. 2020 г. в 19:44, Alexander Kukushkin <cyberdemn@gmail.com>:
> >> I know, nobody in their mind should do that, but, if the postmaster
> >> process is killed with SIGKILL signal, most backend processes
> >> correctly notice the fact of the postmaster process absence and exit.
> >> There is one exception though, when there are autovacuum worker
> >> processes they are continuing to run until eventually finish and exit.
>
> > Do you get the same behaviour also on master?
> > As there was some work in this area for 14, see
> > https://git.postgresql.org/pg/commitdiff/44fc6e259b
>
> That was about SIGQUIT response, which isn't really related to this
> scenario.  But I do not think Alexander has accurately characterized
> the situation.  *No* server processes will react instantly to postmaster
> death.  Typically they'll only detect it while waiting for some other
> condition, such as client input, or in some cases while iterating their
> outermost loop.  So if they're busy with calculations they might not
> notice for a long time.  I don't think autovacuum is any worse than
> a busy client backend on this score.

Considering how long an autovacuum can run, it seems like it'd be
worthwhile to find a useful place to check for postmaster-death.
Typical well-running systems are going to be waiting for the client
pretty frequently and therefore this does make autovacuum stick out in
this case.

> It's hard to do better than that, because on most platforms there's
> no way to get a signal on parent-process death, so the only way to
> notice would be to poll the postmaster-death pipe constantly; which
> would be hugely expensive in comparison to the value.

I agree that 'constantly' wouldn't be great, but with some periodicity
that's more frequent than 'not until a few hours later when we finally
finish vacuuming this relation' would be nice.  At least with autovauum
we may be periodically sleeping anyway so it doesn't seem like polling
at that point would really be terrible, though it'd be nice to check
every once in a while even if we aren't sleeping.

Thanks,

Stephen

Attachment

pgsql-hackers by date:

Previous
From: Magnus Hagander
Date:
Subject: Re: -O switch
Next
From: Tom Lane
Date:
Subject: Re: -O switch