Re: make the stats collector shutdown without writing the statsfiles if the immediate shutdown is requested.

From: Andres Freund <andres(at)anarazel(dot)de>
To: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
Cc: Masahiro Ikeda <ikedamsh(at)oss(dot)nttdata(dot)com>, kuroda(dot)hayato(at)fujitsu(dot)com, Zhihong Yu <zyu(at)yugabyte(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: make the stats collector shutdown without writing the statsfiles if the immediate shutdown is requested.
Date: 2021-03-26 17:11:25
Message-ID: 20210326171125.dqawynwznrgj6fiz@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 2021-03-25 21:23:17 +0900, Fujii Masao wrote:
> > This strikes me as a quite a misleading function name.
>
> Yeah, better name is always welcome :)

It might just be best to not introduce a generic function and just open
code one just for the stats collector...

> > Outside of very
> > narrow circumstances a normal exit shouldn't use _exit(1). Neither 1 no
> > _exit() (as opposed to exit()) seem appropriate. This seems like a bad
> > idea.
>
> So you're thinking that the stats collector should do proc_exit(0)
> or something even when it receives immediate shutdown request?

> One idea to avoid using _exit(1) is to change the SIGQUIT handler
> so that it just sets the flag. Then if the stats collector detects that
> the flag is set in the main loop, it gets out of the loop,
> skips writing the permanent stats file and then exits with exit(0).
> That is, normal and immediate shutdown requests are treated
> almost the same way in the stats collector. Only the difference of
> them is whether it saves the stats to the file or not. Thought?

My main complaint isn't so much that you made the stats collector
_exit(1). It's that that you added a function that sounded generic, but
should basically not be used anywhere (we have very few non-shmem
connected processes left - I don't think that number will increase).

Greetings,

Andres Freund

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2021-03-26 17:14:36 Re: make the stats collector shutdown without writing the statsfiles if the immediate shutdown is requested.
Previous Message Andres Freund 2021-03-26 17:07:45 Re: wal stats questions