pgsql: Restrict copying of invalidated replication slots.

From: Masahiko Sawada <msawada(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Restrict copying of invalidated replication slots.
Date: 2025-04-03 17:30:29
Message-ID: E1u0OOb-002Uhy-0D@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Restrict copying of invalidated replication slots.

Previously, invalidated logical and physical replication slots could
be copied using the pg_copy_logical_replication_slot and
pg_copy_physical_replication_slot functions. Replication slots that
were invalidated for reasons other than WAL removal retained their
restart_lsn. This meant that a new slot copied from an invalidated
slot could have a restart_lsn pointing to a WAL segment that might
have already been removed.

This commit restricts the copying of invalidated replication slots.

Backpatch to v16, where slots could retain their restart_lsn when
invalidated for reasons other than WAL removal.

For v15 and earlier, this check is not required since slots can only
be invalidated due to WAL removal, and existing checks already handle
this issue.

Author: Shlok Kyal <shlok(dot)kyal(dot)oss(at)gmail(dot)com>
Reviewed-by: vignesh C <vignesh21(at)gmail(dot)com>
Reviewed-by: Zhijie Hou <houzj(dot)fnst(at)fujitsu(dot)com>
Reviewed-by: Peter Smith <smithpb2250(at)gmail(dot)com>
Reviewed-by: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Reviewed-by: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Discussion: https://postgr.es/m/CANhcyEU65aH0VYnLiu%3DOhNNxhnhNhwcXBeT-jvRe1OiJTo_Ayg%40mail.gmail.com
Backpatch-through: 16

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/fd09c1316bc37773d115d918dded660a7f5f08fb

Modified Files
--------------
doc/src/sgml/func.sgml | 6 ++++--
src/backend/replication/slotfuncs.c | 21 +++++++++++++++++++++
src/test/recovery/t/035_standby_logical_decoding.pl | 9 +++++++++
3 files changed, 34 insertions(+), 2 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Masahiko Sawada 2025-04-03 17:30:32 pgsql: Restrict copying of invalidated replication slots.
Previous Message Noah Misch 2025-04-03 16:36:55 pgsql: Add helper library for use of libpq inside the server environmen