pgsql: Move replication slot release to before_shmem_exit(). - Mailing list pgsql-committers

From Andres Freund
Subject pgsql: Move replication slot release to before_shmem_exit().
Date
Msg-id E1nJmLp-0001ym-3x@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Move replication slot release to before_shmem_exit().

Previously, replication slots were released in ProcKill() on error, resulting
in reporting replication slot drop of ephemeral slots after the stats
subsystem was already shut down.

To fix this problem, move replication slot release to a before_shmem_exit()
hook that is called before the stats collector shuts down. There wasn't really
a good reason for the slot handling to be in ProcKill() anyway.

Patch by Masahiko Sawada, with very minor polishing by me.

I, Andres, wrote a test for dropping slots during process exit, but there may
be some OS dependent issues around the number of times FATAL error messages
are displayed due to a still debated libpq issue. So that test will be
committed separately / later.

Reviewed-By: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Reviewed-By: Andres Freund <andres@anarazel.de>
Author: Masahiko Sawada <sawada.mshk@gmail.com>
Discussion: https://postgr.es/m/CAD21AoDAeEpAbZEyYJsPZJUmSPaRicVSBObaL7sPaofnKz+9zg@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/2f6501fa3c54bbe4568e3bcccd9a60d26a46b5ee

Modified Files
--------------
src/backend/replication/slot.c    | 25 +++++++++++++++++++++++++
src/backend/storage/lmgr/proc.c   |  7 -------
src/backend/tcop/postgres.c       |  4 ++--
src/backend/utils/init/postinit.c |  7 +++++++
src/include/replication/slot.h    |  1 +
5 files changed, 35 insertions(+), 9 deletions(-)


pgsql-committers by date:

Previous
From: Peter Eisentraut
Date:
Subject: pgsql: Remove one use of pg_atoi()
Next
From: Michael Paquier
Date:
Subject: pgsql: Fix thinko with subdirectories generated by pg_upgrade for inter