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

From: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
To: Masahiro Ikeda <ikedamsh(at)oss(dot)nttdata(dot)com>
Cc: 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-19 04:33:58
Message-ID: bca0b1ef-a7fc-c958-761d-a49293dfdade@oss.nttdata.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2021/03/18 19:16, Masahiro Ikeda wrote:
> As you said, the temporary stats files don't removed if the stats collector is killed with SIGQUIT.
> So, if the user change the GUC parameter "stats_temp_directory" after immediate shutdown,
> temporary stats file can't be removed forever.
>
> But, I think this case is rarely happened and unimportant. Actually, pgstat_write_statsfiles()
> didn't check error of unlink() and the same problem is occurred if the server is crashed now.
> The documentation said following. I think it's enough.

Thanks for considering this! Understood.

> I don't have any strong opinion this behaivor is useless too.
>
> Since the reinitialized phase is not executed when only the stats collector is crashed
> (since it didn't touch the shared memory), if the permanent stats file is exists, the
> stats collector can use it. But, IIUC, the case is rare.
>
> The case is happened by operation mistake which a operator sends the SIGQUIT signal to
> the stats collector. Please let me know if there are more important case.
>
> But, if SIGKILL is sent by operator, the stats can't be rescure now because the permanent stats
> files can't be written before exiting. Since the case which can rescure the stats is rare,
> I think it's ok to initialize the stats even if SIGQUIT is sent.

Sounds reasonable.

>> When only the stats collector exits by SIGQUIT, with the patch
>> FreeWaitEventSet() is also skipped. Is this ok?
>
> Thanks, I fixed it.

I'm still not sure if FreeWaitEventSet() is actually necessary in that
exit case. Could you tell me why you thought FreeWaitEventSet() is
necessary in the case?

Since it's not good to do many things in a signal handler, even when
FreeWaitEventSet() is really necessary, it should be called at subsequent
startup of the stats collector instead of calling it in the handler
at the end? BTW, I found bgworker calls FreeWaitEventSet() via
ShutdownLatchSupport() at its startup. But I'm also not sure if this
is really necessary at the startup...

Regards,

--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tatsuo Ishii 2021-03-19 04:53:34 Re: Using COPY FREEZE in pgbench
Previous Message Amit Kapila 2021-03-19 03:35:13 Re: Logical Replication vs. 2PC