a significant number of WaitLatch's in the backend currently don't check
for postmaster death. That's imo wrong.  E.g. SELECT pg_sleep(100); just
continues to run.

I think we should change most sites to error out in that case. I wonder
if we shouldn't add another WL_ flag that automatically makes the latch
code do so; instead of repeating the code at every callsite.

Places that I've noticed in a quick skim:
* pg_sleep()
* gather_getnext()
* shm_mq_send_bytes()?
* shm_mq_receive_bytes()?
* ProcSleep()?
* ProcWaitForSignal()

The only case where we don't necessarily want to react to postmaster
death is syslogger, which is supposed to finish logging before shutting

Additionally I noticed that we're not always diligent about following
the correct pattern when using latches. For example check
                        /* Nothing to do except wait for developments. */
                        WaitLatch(MyLatch, WL_LATCH_SET, 0);
we should reset the latch before checking for interrupts, not
after. This way an interrupt that arrives between the two will possibly
be ignored.


Andres Freund

Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:

Reply via email to