Restrict copying of invalidated replication slots.
authorMasahiko Sawada <[email protected]>
Thu, 3 Apr 2025 17:30:02 +0000 (10:30 -0700)
committerMasahiko Sawada <[email protected]>
Thu, 3 Apr 2025 17:30:02 +0000 (10:30 -0700)
commita4309e85f4614315584e67737ea7b5efa19fb24c
tree87a833d140c5c81b5b4e9237acc445be5cc5a2c4
parente0191121b2f0ef86138400fb89b150d0ae7353b7
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 <[email protected]>
Reviewed-by: vignesh C <[email protected]>
Reviewed-by: Zhijie Hou <[email protected]>
Reviewed-by: Peter Smith <[email protected]>
Reviewed-by: Masahiko Sawada <[email protected]>
Reviewed-by: Amit Kapila <[email protected]>
Discussion: https://postgr.es/m/CANhcyEU65aH0VYnLiu%3DOhNNxhnhNhwcXBeT-jvRe1OiJTo_Ayg%40mail.gmail.com
Backpatch-through: 16
doc/src/sgml/func.sgml
src/backend/replication/slotfuncs.c
src/test/recovery/t/035_standby_logical_decoding.pl