pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix race condition in invalidating obsolete replication slots
Date: Fri, 11 Jun 2021 16:21:15 +0000
Message-ID: <E1lrjuF-00065G-DM@gemulon.postgresql.org> (raw)

Fix race condition in invalidating obsolete replication slots

The code added to mark replication slots invalid in commit c6550776394e
had the race condition that a slot can be dropped or advanced
concurrently with checkpointer trying to invalidate it.  Rewrite the
code to close those races.

The changes to ReplicationSlotAcquire's API added with c6550776394e are
not necessary anymore.  To avoid an ABI break in released branches, this
commit leaves that unchanged; it'll be changed in a master-only commit
separately.

Backpatch to 13, where this code first appeared.

Reported-by: Andres Freund <andres@anarazel.de>
Author: Andres Freund <andres@anarazel.de>
Author: Álvaro Herrera <alvherre@alvh.no-ip.org>
Discussion: https://postgr.es/m/20210408001037.wfmk6jud36auhfqm@alap3.anarazel.de

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/218b101008b533156d7e5832fe143d1e04a01301

Modified Files
--------------
src/backend/replication/slot.c | 223 +++++++++++++++++++++++++++--------------
1 file changed, 145 insertions(+), 78 deletions(-)



view thread (2+ messages)

Message-ID: <E1lrjuF-00065G-DM@gemulon.postgresql.org>
Permalink:  ../E1lrjuF-00065G-DM@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1lrjuF-00065G-DM@gemulon.postgresql.org

 · 

reply

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: alvherre@alvh.no-ip.org
  Subject: Re: pgsql: Fix race condition in invalidating obsolete replication slots
  In-Reply-To: <E1lrjuF-00065G-DM@gemulon.postgresql.org>
  References: <E1lrjuF-00065G-DM@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