diff options
| author | Amit Kapila | 2025-01-31 04:57:35 +0000 |
|---|---|---|
| committer | Amit Kapila | 2025-01-31 04:57:35 +0000 |
| commit | f41d8468ddea34170fe19fdc17b5a247e7d3ac78 (patch) | |
| tree | 579d85e4ea52344a862f78b4725541fa5aa16d35 /src/test | |
| parent | a632cd354d35e1c3352061c375b4458876c9f10a (diff) | |
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.moond412@gmail.com>
Author: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Reviewed-by: Vignesh C <vignesh21@gmail.com>
Reviewed-by: Peter Smith <smithpb2250@gmail.com>
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Discussion: https://postgr.es/m/CABdArM6pBL5hPnSQ+5nEVMANcF4FCH7LQmgskXyiLY75TMnKpw@mail.gmail.com
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/recovery/t/019_replslot_limit.pl | 2 | ||||
| -rw-r--r-- | src/test/recovery/t/035_standby_logical_decoding.pl | 15 |
2 files changed, 7 insertions, 10 deletions
diff --git a/src/test/recovery/t/019_replslot_limit.pl b/src/test/recovery/t/019_replslot_limit.pl index ae2ad5c933a..6468784b83d 100644 --- a/src/test/recovery/t/019_replslot_limit.pl +++ b/src/test/recovery/t/019_replslot_limit.pl @@ -234,7 +234,7 @@ my $failed = 0; for (my $i = 0; $i < 10 * $PostgreSQL::Test::Utils::timeout_default; $i++) { if ($node_standby->log_contains( - "requested WAL segment [0-9A-F]+ has already been removed", + "This replication slot has been invalidated due to \"wal_removed\".", $logstart)) { $failed = 1; diff --git a/src/test/recovery/t/035_standby_logical_decoding.pl b/src/test/recovery/t/035_standby_logical_decoding.pl index 7e794c5bea3..505e85d1eb6 100644 --- a/src/test/recovery/t/035_standby_logical_decoding.pl +++ b/src/test/recovery/t/035_standby_logical_decoding.pl @@ -533,7 +533,7 @@ check_slots_conflict_reason('vacuum_full_', 'rows_removed'); qq[ALTER_REPLICATION_SLOT vacuum_full_inactiveslot (failover);], replication => 'database'); ok( $stderr =~ - /ERROR: cannot alter invalid replication slot "vacuum_full_inactiveslot"/ + /ERROR: can no longer access replication slot "vacuum_full_inactiveslot"/ && $stderr =~ /DETAIL: This replication slot has been invalidated due to "rows_removed"./, "invalidated slot cannot be altered"); @@ -551,8 +551,7 @@ $handle = # We are not able to read from the slot as it has been invalidated check_pg_recvlogical_stderr($handle, - "can no longer get changes from replication slot \"vacuum_full_activeslot\"" -); + "can no longer access replication slot \"vacuum_full_activeslot\""); # Turn hot_standby_feedback back on change_hot_standby_feedback_and_wait_for_xmins(1, 1); @@ -632,8 +631,7 @@ $handle = # We are not able to read from the slot as it has been invalidated check_pg_recvlogical_stderr($handle, - "can no longer get changes from replication slot \"row_removal_activeslot\"" -); + "can no longer access replication slot \"row_removal_activeslot\""); ################################################## # Recovery conflict: Same as Scenario 2 but on a shared catalog table @@ -668,7 +666,7 @@ $handle = make_slot_active($node_standby, 'shared_row_removal_', 0, \$stdout, # We are not able to read from the slot as it has been invalidated check_pg_recvlogical_stderr($handle, - "can no longer get changes from replication slot \"shared_row_removal_activeslot\"" + "can no longer access replication slot \"shared_row_removal_activeslot\"" ); ################################################## @@ -759,7 +757,7 @@ $handle = make_slot_active($node_standby, 'pruning_', 0, \$stdout, \$stderr); # We are not able to read from the slot as it has been invalidated check_pg_recvlogical_stderr($handle, - "can no longer get changes from replication slot \"pruning_activeslot\""); + "can no longer access replication slot \"pruning_activeslot\""); # Turn hot_standby_feedback back on change_hot_standby_feedback_and_wait_for_xmins(1, 1); @@ -818,8 +816,7 @@ $handle = make_slot_active($node_standby, 'wal_level_', 0, \$stdout, \$stderr); # as the slot has been invalidated we should not be able to read check_pg_recvlogical_stderr($handle, - "can no longer get changes from replication slot \"wal_level_activeslot\"" -); + "can no longer access replication slot \"wal_level_activeslot\""); ################################################## # DROP DATABASE should drop its slots, including active slots. |
