diff options
author | Andres Freund <andres@anarazel.de> | 2022-02-14 16:44:28 -0800 |
---|---|---|
committer | Andres Freund <andres@anarazel.de> | 2022-02-14 17:08:17 -0800 |
commit | 2f6501fa3c54bbe4568e3bcccd9a60d26a46b5ee (patch) | |
tree | e1ced75463fc0cbb0de404d27d6227ecef1e5663 /src/backend/tcop/postgres.c | |
parent | b45fa793406d6007a787c586c1960b1ffc2ef2fb (diff) | |
download | postgresql-2f6501fa3c54bbe4568e3bcccd9a60d26a46b5ee.tar.gz postgresql-2f6501fa3c54bbe4568e3bcccd9a60d26a46b5ee.zip |
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
Diffstat (limited to 'src/backend/tcop/postgres.c')
-rw-r--r-- | src/backend/tcop/postgres.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index fda2e9360e2..38d8b97894c 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -4261,8 +4261,8 @@ PostgresMain(const char *dbname, const char *username) * We can't release replication slots inside AbortTransaction() as we * need to be able to start and abort transactions while having a slot * acquired. But we never need to hold them across top level errors, - * so releasing here is fine. There's another cleanup in ProcKill() - * ensuring we'll correctly cleanup on FATAL errors as well. + * so releasing here is fine. There also is a before_shmem_exit() + * callback ensuring correct cleanup on FATAL errors. */ if (MyReplicationSlot != NULL) ReplicationSlotRelease(); |