Raise an error while trying to acquire an invalid slot. Once a replication slot is invalidated, it cannot be altered or used to fetch changes. However, a process could still acquire an invalid slot and fail later.
For example, if a process acquires a logical slot that was invalidated due to wal_removed, it will eventually fail in CreateDecodingContext() when attempting to access the removed WAL. Similarly, for physical replication slots, even if the slot is invalidated and invalidation_reason is set to wal_removed, the walsender does not currently check for invalidation when starting physical replication. Instead, replication starts, and an error is only reported later while trying to access WAL. Similarly, we prohibit modifying slot properties for invalid slots but give the error for the same after acquiring the slot. This patch improves error handling by detecting invalid slots earlier at the time of slot acquisition which is the first step. This also helped in unifying different ERROR messages at different places and gave a consistent message for invalid slots. This means that the message for invalid slots will change to a generic message. This will also be helpful for future patches where we are planning to invalidate slots due to more reasons like idle_timeout because we don't have to modify multiple places in such cases and avoid the chances of missing out on a particular place. Author: Nisha Moond <nisha.moond...@gmail.com> Author: Bharath Rupireddy <bharath.rupireddyforpostg...@gmail.com> Reviewed-by: Vignesh C <vignes...@gmail.com> Reviewed-by: Peter Smith <smithpb2...@gmail.com> Reviewed-by: Hayato Kuroda <kuroda.hay...@fujitsu.com> Reviewed-by: Amit Kapila <amit.kapil...@gmail.com> Discussion: https://postgr.es/m/cabdarm6pbl5hpnsq+5nevmancf4fch7lqmgskxyily75tmn...@mail.gmail.com Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/f41d8468ddea34170fe19fdc17b5a247e7d3ac78 Modified Files -------------- src/backend/replication/logical/logical.c | 25 +++--------------- src/backend/replication/logical/logicalfuncs.c | 2 +- src/backend/replication/logical/slotsync.c | 4 +-- src/backend/replication/slot.c | 30 ++++++++++++++-------- src/backend/replication/slotfuncs.c | 2 +- src/backend/replication/walsender.c | 4 +-- src/backend/utils/adt/pg_upgrade_support.c | 2 +- src/include/replication/slot.h | 3 ++- src/test/recovery/t/019_replslot_limit.pl | 2 +- .../recovery/t/035_standby_logical_decoding.pl | 15 +++++------ 10 files changed, 39 insertions(+), 50 deletions(-)