pgsql: Move replication slot release to before_shmem_exit().

From: Andres Freund <andres(at)anarazel(dot)de>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Move replication slot release to before_shmem_exit().
Date: 2022-02-15 01:09:53
Message-ID: E1nJmLp-0001ym-3x@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(dot)ntt(at)gmail(dot)com>
Reviewed-By: Andres Freund <andres(at)anarazel(dot)de>
Author: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)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(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2022-02-15 02:47:41 pgsql: Fix thinko with subdirectories generated by pg_upgrade for inter
Previous Message Peter Eisentraut 2022-02-14 22:17:45 pgsql: Remove one use of pg_atoi()