From: Thomas Munro <tmunro@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Add WL_EXIT_ON_PM_DEATH pseudo-event.
Date: Fri, 23 Nov 2018 07:54:42 +0000
Message-ID: <E1gQ6IU-0002sR-Fm@gemulon.postgresql.org> (raw)
Add WL_EXIT_ON_PM_DEATH pseudo-event.
Users of the WaitEventSet and WaitLatch() APIs can now choose between
asking for WL_POSTMASTER_DEATH and then handling it explicitly, or asking
for WL_EXIT_ON_PM_DEATH to trigger immediate exit on postmaster death.
This reduces code duplication, since almost all callers want the latter.
Repair all code that was previously ignoring postmaster death completely,
or requesting the event but ignoring it, or requesting the event but then
doing an unconditional PostmasterIsAlive() call every time through its
event loop (which is an expensive syscall on platforms for which we don't
have USE_POSTMASTER_DEATH_SIGNAL support).
Assert that callers of WaitLatchXXX() under the postmaster remember to
ask for either WL_POSTMASTER_DEATH or WL_EXIT_ON_PM_DEATH, to prevent
future bugs.
The only process that doesn't handle postmaster death is syslogger. It
waits until all backends holding the write end of the syslog pipe
(including the postmaster) have closed it by exiting, to be sure to
capture any parting messages. By using the WaitEventSet API directly
it avoids the new assertion, and as a by-product it may be slightly
more efficient on platforms that have epoll().
Author: Thomas Munro
Reviewed-by: Kyotaro Horiguchi, Heikki Linnakangas, Tom Lane
Discussion: https://postgr.es/m/CAEepm%3D1TCviRykkUb69ppWLr_V697rzd1j3eZsRMmbXvETfqbQ%40mail.gmail.com,
https://postgr.es/m/CAEepm=2LqHzizbe7muD7-2yHUbTOoF7Q+qkSD5Q41kuhttRTwA@mail.gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/cfdf4dc4fc9635ac8bf6eaaa5dbbcd364ab29f0c
Modified Files
--------------
- | 0
contrib/pg_prewarm/autoprewarm.c | 8 ++--
contrib/postgres_fdw/connection.c | 6 ++-
src/backend/access/transam/parallel.c | 10 ++---
src/backend/access/transam/xlog.c | 23 +++++-----
src/backend/access/transam/xlogfuncs.c | 8 ++--
src/backend/executor/nodeGather.c | 3 +-
src/backend/libpq/be-secure-openssl.c | 4 +-
src/backend/libpq/pqmq.c | 4 +-
src/backend/postmaster/autovacuum.c | 16 ++-----
src/backend/postmaster/bgwriter.c | 11 +----
src/backend/postmaster/checkpointer.c | 16 ++-----
src/backend/postmaster/pgarch.c | 4 +-
src/backend/postmaster/syslogger.c | 38 ++++++++++-------
src/backend/postmaster/walwriter.c | 16 ++-----
src/backend/replication/basebackup.c | 2 +-
.../libpqwalreceiver/libpqwalreceiver.c | 13 +-----
src/backend/replication/logical/launcher.c | 24 ++---------
src/backend/replication/logical/tablesync.c | 30 ++++---------
src/backend/replication/logical/worker.c | 6 +--
src/backend/replication/syncrep.c | 18 ++++----
src/backend/replication/walreceiver.c | 22 ++--------
src/backend/replication/walsender.c | 49 +++++++---------------
src/backend/storage/ipc/latch.c | 38 ++++++++++++++++-
src/backend/storage/ipc/shm_mq.c | 9 ++--
src/backend/storage/lmgr/condition_variable.c | 14 ++-----
src/backend/storage/lmgr/proc.c | 7 ++--
src/backend/utils/adt/misc.c | 2 +-
src/include/storage/latch.h | 3 +-
src/test/modules/test_shm_mq/setup.c | 3 +-
src/test/modules/test_shm_mq/test.c | 3 +-
src/test/modules/worker_spi/worker_spi.c | 6 +--
32 files changed, 174 insertions(+), 242 deletions(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: tmunro@postgresql.org
Subject: Re: pgsql: Add WL_EXIT_ON_PM_DEATH pseudo-event.
In-Reply-To: <E1gQ6IU-0002sR-Fm@gemulon.postgresql.org>
References: <E1gQ6IU-0002sR-Fm@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox