On 24/02/2026 10:00, Alexander Lakhin wrote:
Could you please look at a new failure of 035_standby_logical_decoding.pl
produced at buildfarm [1]?:
[05:34:51.345](233.134s) # poll_query_until timed out executing this query:
# SELECT '0/0403F950' <= replay_lsn AND state = 'streaming'
#          FROM pg_catalog.pg_stat_replication
#          WHERE application_name IN ('standby', 'walreceiver')
# expecting this output:
# t
# last actual query output:
# f
# with stderr:

035_standby_logical_decoding_standby.log contains:
2026-02-24 05:30:58.300 CET [1512377][client backend][:0] LOG: disconnection: session time: 0:00:00.035 user=bf database=testdb host=[local] 2026-02-24 05:30:58.425 CET [1507982][startup][32/0:0] LOG: invalidating obsolete replication slot "row_removal_inactiveslot" 2026-02-24 05:30:58.425 CET [1507982][startup][32/0:0] DETAIL:  The slot conflicted with xid horizon 748. 2026-02-24 05:30:58.425 CET [1507982][startup][32/0:0] CONTEXT:  WAL redo at 0/040214F0 for Heap2/PRUNE_ON_ACCESS: snapshotConflictHorizon: 748, isCatalogRel: T, nplans: 0, nredirected: 0, ndead: 3, nunused: 1, dead: [33, 34, 35], unused: [36]; blkref #0: rel 1663/16384/16418, blk 10 2026-02-24 05:30:58.425 CET [1507982][startup][32/0:0] LOG: terminating process 1512360 to release replication slot "row_removal_activeslot" 2026-02-24 05:30:58.425 CET [1507982][startup][32/0:0] DETAIL:  The slot conflicted with xid horizon 748. 2026-02-24 05:30:58.425 CET [1507982][startup][32/0:0] CONTEXT:  WAL redo at 0/040214F0 for Heap2/PRUNE_ON_ACCESS: snapshotConflictHorizon: 748, isCatalogRel: T, nplans: 0, nredirected: 0, ndead: 3, nunused: 1, dead: [33, 34, 35], unused: [36]; blkref #0: rel 1663/16384/16418, blk 10 2026-02-24 05:34:51.400 CET [1508227][walreceiver][:0] FATAL:  could not receive data from WAL stream: server closed the connection unexpectedly
         This probably means the server terminated abnormally
         before or while processing the request.

The "terminating process ..." message doesn't appear when the test passes
successfully.

Hmm, right, looks like something wrong in signaling the recovery conflict. I can't tell if the signal is being sent, or it's not processed correctly. Looking at the code, I don't see anything wrong.

I've managed to reproduce this with multiple (20) test instances running
in a loop (it failed within 10 iterations for me); `git bisect` for this
anomaly pointed at 17f51ea81.

I've been trying to reproduce this locally, but so far not success, after thousands of iterations.

If you can still reproduce this, can you try it with code changes from the attached recovery-conflict-fail-extra-logging.patch, which adds some extra logging, and send over the logs please?

The recovery-conflict-fail-repro-attempt.patch contains very hacky changes to the test, to run the just the failing part 100 times in a loop. That's just to show what I used to try to reproduce this, but no luck.

- Heikki
diff --git a/src/backend/replication/slot.c b/src/backend/replication/slot.c
index 28c7019402b..cc25abbb5ce 100644
--- a/src/backend/replication/slot.c
+++ b/src/backend/replication/slot.c
@@ -2122,6 +2122,8 @@ InvalidatePossiblyObsoleteSlot(uint32 possible_causes,
 
 				last_signaled_pid = active_pid;
 			}
+			else
+				elog(LOG, "XXX: same process (%d) is still blocking us, not signaling again", active_pid);
 
 			/* Wait until the slot is released. */
 			ConditionVariableSleep(&s->active_cv,
diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c
index 40312df2cac..c82761f5da3 100644
--- a/src/backend/storage/ipc/procarray.c
+++ b/src/backend/storage/ipc/procarray.c
@@ -3473,6 +3473,8 @@ SignalRecoveryConflict(PGPROC *proc, pid_t pid, RecoveryConflictReason reason)
 		(void) SendProcSignal(pid, PROCSIG_RECOVERY_CONFLICT, GetNumberFromPGProc(proc));
 		found = true;
 	}
+	else
+		elog(LOG, "XXX: SignalRecoveryConflict signaling pid %d, because it's gone (proc->pid == %d)", pid, proc->pid);
 
 	LWLockRelease(ProcArrayLock);
 
diff --git a/src/backend/storage/ipc/procsignal.c b/src/backend/storage/ipc/procsignal.c
index d47d180a32f..b561dc64265 100644
--- a/src/backend/storage/ipc/procsignal.c
+++ b/src/backend/storage/ipc/procsignal.c
@@ -289,19 +289,24 @@ SendProcSignal(pid_t pid, ProcSignalReason reason, ProcNumber procNumber)
 
 	if (procNumber != INVALID_PROC_NUMBER)
 	{
+		uint32 slot_pid;
 		Assert(procNumber < NumProcSignalSlots);
 		slot = &ProcSignal->psh_slot[procNumber];
 
 		SpinLockAcquire(&slot->pss_mutex);
-		if (pg_atomic_read_u32(&slot->pss_pid) == pid)
+		slot_pid = pg_atomic_read_u32(&slot->pss_pid);
+		if (slot_pid == pid)
 		{
 			/* Atomically set the proper flag */
 			slot->pss_signalFlags[reason] = true;
 			SpinLockRelease(&slot->pss_mutex);
+			elog(LOG, "XXX: SendProcSignal sending SIGUSR1 to pid %d", pid);
 			/* Send signal */
 			return kill(pid, SIGUSR1);
 		}
 		SpinLockRelease(&slot->pss_mutex);
+		elog(LOG, "XXX: SendProcSignal NOT sending SIGUSR1 to pid %d, because it's gone (slot->pss_pid %u)",
+			 pid, slot_pid);
 	}
 	else
 	{
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index d01a09dd0c4..734ff056dad 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -3182,6 +3182,9 @@ report_recovery_conflict(RecoveryConflictReason reason)
 {
 	bool		fatal;
 
+	elog(LOG, "XXX: report_recovery_conflict called; reason %d; IsAbortedTransactionBlockState() %d; DoingCommandRead %d; QueryCancelHoldoffCount %d",
+		 reason, IsAbortedTransactionBlockState(), DoingCommandRead, QueryCancelHoldoffCount);
+
 	if (reason == RECOVERY_CONFLICT_DATABASE)
 	{
 		/* note: no hint about reconnecting, and different errcode */
diff --git a/src/test/recovery/meson.build b/src/test/recovery/meson.build
index 8d20488952e..b3ecc32b5e6 100644
--- a/src/test/recovery/meson.build
+++ b/src/test/recovery/meson.build
@@ -10,56 +10,7 @@ tests += {
        'enable_injection_points': get_option('injection_points') ? 'yes' : 'no',
     },
     'tests': [
-      't/001_stream_rep.pl',
-      't/002_archiving.pl',
-      't/003_recovery_targets.pl',
-      't/004_timeline_switch.pl',
-      't/005_replay_delay.pl',
-      't/006_logical_decoding.pl',
-      't/007_sync_rep.pl',
-      't/008_fsm_truncation.pl',
-      't/009_twophase.pl',
-      't/010_logical_decoding_timelines.pl',
-      't/012_subtransactions.pl',
-      't/013_crash_restart.pl',
-      't/014_unlogged_reinit.pl',
-      't/015_promotion_pages.pl',
-      't/016_min_consistency.pl',
-      't/017_shm.pl',
-      't/018_wal_optimize.pl',
-      't/019_replslot_limit.pl',
-      't/020_archive_status.pl',
-      't/021_row_visibility.pl',
-      't/022_crash_temp_files.pl',
-      't/023_pitr_prepared_xact.pl',
-      't/024_archive_recovery.pl',
-      't/025_stuck_on_old_timeline.pl',
-      't/026_overwrite_contrecord.pl',
-      't/027_stream_regress.pl',
-      't/028_pitr_timelines.pl',
-      't/029_stats_restart.pl',
-      't/030_stats_cleanup_replica.pl',
-      't/031_recovery_conflict.pl',
-      't/032_relfilenode_reuse.pl',
-      't/033_replay_tsp_drops.pl',
-      't/034_create_database.pl',
       't/035_standby_logical_decoding.pl',
-      't/036_truncated_dropped.pl',
-      't/037_invalid_database.pl',
-      't/038_save_logical_slots_shutdown.pl',
-      't/039_end_of_wal.pl',
-      't/040_standby_failover_slots_sync.pl',
-      't/041_checkpoint_at_promote.pl',
-      't/042_low_level_backup.pl',
-      't/043_no_contrecord_switch.pl',
-      't/044_invalidate_inactive_slots.pl',
-      't/045_archive_restartpoint.pl',
-      't/046_checkpoint_logical_slot.pl',
-      't/047_checkpoint_physical_slot.pl',
-      't/048_vacuum_horizon_floor.pl',
-      't/049_wait_for_lsn.pl',
-      't/050_redo_segment_missing.pl',
-      't/051_effective_wal_level.pl',
     ],
   },
 }
diff --git a/src/test/recovery/t/035_standby_logical_decoding.pl b/src/test/recovery/t/035_standby_logical_decoding.pl
index d264a698ff6..8bca0d0dec3 100644
--- a/src/test/recovery/t/035_standby_logical_decoding.pl
+++ b/src/test/recovery/t/035_standby_logical_decoding.pl
@@ -22,7 +22,6 @@ my $node_primary = PostgreSQL::Test::Cluster->new('primary');
 my $node_standby = PostgreSQL::Test::Cluster->new('standby');
 my $node_cascading_standby =
   PostgreSQL::Test::Cluster->new('cascading_standby');
-my $node_subscriber = PostgreSQL::Test::Cluster->new('subscriber');
 my $default_timeout = $PostgreSQL::Test::Utils::timeout_default;
 my $res;
 
@@ -329,6 +328,9 @@ $node_primary->backup($backup_name);
 # WAL. An insert into flush_wal outside transaction does guarantee a flush.
 $node_primary->psql('testdb', q[CREATE TABLE flush_wal();]);
 
+# Create the injection_points extension
+$node_primary->safe_psql('testdb', 'CREATE EXTENSION injection_points;');
+
 #######################
 # Initialize standby node
 #######################
@@ -344,347 +346,20 @@ $node_standby->append_conf(
 $node_standby->start;
 $node_primary->wait_for_replay_catchup($node_standby);
 
-#######################
-# Initialize subscriber node
-#######################
-$node_subscriber->init;
-$node_subscriber->start;
-
-my %psql_subscriber = (
-	'subscriber_stdin' => '',
-	'subscriber_stdout' => '',
-	'subscriber_stderr' => '');
-$psql_subscriber{run} = IPC::Run::start(
-	[
-		'psql', '--no-psqlrc', '--no-align',
-		'--file' => '-',
-		'--dbname' => $node_subscriber->connstr('postgres')
-	],
-	'<' => \$psql_subscriber{subscriber_stdin},
-	'>' => \$psql_subscriber{subscriber_stdout},
-	'2>' => \$psql_subscriber{subscriber_stderr},
-	IPC::Run::timeout($default_timeout));
-
-##################################################
-# Test that the standby requires hot_standby to be
-# enabled for pre-existing logical slots.
-##################################################
-
-# create the logical slots
-$node_standby->create_logical_slot_on_standby($node_primary, 'restart_test');
-$node_standby->stop;
-$node_standby->append_conf('postgresql.conf', qq[hot_standby = off]);
-
-# Use run_log instead of $node_standby->start because this test expects
-# that the server ends with an error during startup.
-run_log(
-	[
-		'pg_ctl',
-		'--pgdata' => $node_standby->data_dir,
-		'--log' => $node_standby->logfile,
-		'start',
-	]);
-
-# wait for postgres to terminate
-foreach my $i (0 .. 10 * $PostgreSQL::Test::Utils::timeout_default)
-{
-	last if !-f $node_standby->data_dir . '/postmaster.pid';
-	usleep(100_000);
-}
-
-# Confirm that the server startup fails with an expected error
-my $logfile = slurp_file($node_standby->logfile());
-like(
-	$logfile,
-	qr/FATAL: .* logical replication slot ".*" exists on the standby, but "hot_standby" = "off"/,
-	"the standby ends with an error during startup because hot_standby was disabled"
-);
-$node_standby->adjust_conf('postgresql.conf', 'hot_standby', 'on');
-$node_standby->start;
-$node_standby->safe_psql('postgres',
-	qq[SELECT pg_drop_replication_slot('restart_test')]);
-
-##################################################
-# Test that logical decoding on the standby
-# behaves correctly.
-##################################################
-
-# create the logical slots
-create_logical_slots($node_standby, 'behaves_ok_');
-
-$node_primary->safe_psql('testdb',
-	qq[CREATE TABLE decoding_test(x integer, y text);]);
-$node_primary->safe_psql('testdb',
-	qq[INSERT INTO decoding_test(x,y) SELECT s, s::text FROM generate_series(1,10) s;]
-);
-
-$node_primary->wait_for_replay_catchup($node_standby);
-
-my $result = $node_standby->safe_psql('testdb',
-	qq[SELECT pg_logical_slot_get_changes('behaves_ok_activeslot', NULL, NULL);]
-);
-
-# test if basic decoding works
-is(scalar(my @foobar = split /^/m, $result),
-	14, 'Decoding produced 14 rows (2 BEGIN/COMMIT and 10 rows)');
-
-# Insert some rows and verify that we get the same results from pg_recvlogical
-# and the SQL interface.
-$node_primary->safe_psql('testdb',
-	qq[INSERT INTO decoding_test(x,y) SELECT s, s::text FROM generate_series(1,4) s;]
-);
-
-my $expected = q{BEGIN
-table public.decoding_test: INSERT: x[integer]:1 y[text]:'1'
-table public.decoding_test: INSERT: x[integer]:2 y[text]:'2'
-table public.decoding_test: INSERT: x[integer]:3 y[text]:'3'
-table public.decoding_test: INSERT: x[integer]:4 y[text]:'4'
-COMMIT};
-
-$node_primary->wait_for_replay_catchup($node_standby);
-
-my $stdout_sql = $node_standby->safe_psql('testdb',
-	qq[SELECT data FROM pg_logical_slot_peek_changes('behaves_ok_activeslot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');]
-);
-
-is($stdout_sql, $expected, 'got expected output from SQL decoding session');
-
-my $endpos = $node_standby->safe_psql('testdb',
-	"SELECT lsn FROM pg_logical_slot_peek_changes('behaves_ok_activeslot', NULL, NULL) ORDER BY lsn DESC LIMIT 1;"
-);
-
-# Insert some rows after $endpos, which we won't read.
-$node_primary->safe_psql('testdb',
-	qq[INSERT INTO decoding_test(x,y) SELECT s, s::text FROM generate_series(5,50) s;]
-);
-
-$node_primary->wait_for_replay_catchup($node_standby);
-
-my $stdout_recv = $node_standby->pg_recvlogical_upto(
-	'testdb', 'behaves_ok_activeslot', $endpos, $default_timeout,
-	'include-xids' => '0',
-	'skip-empty-xacts' => '1');
-chomp($stdout_recv);
-is($stdout_recv, $expected,
-	'got same expected output from pg_recvlogical decoding session');
-
-$node_standby->poll_query_until('testdb',
-	"SELECT EXISTS (SELECT 1 FROM pg_replication_slots WHERE slot_name = 'behaves_ok_activeslot' AND active_pid IS NULL)"
-) or die "slot never became inactive";
-
-$stdout_recv = $node_standby->pg_recvlogical_upto(
-	'testdb', 'behaves_ok_activeslot', $endpos, $default_timeout,
-	'include-xids' => '0',
-	'skip-empty-xacts' => '1');
-chomp($stdout_recv);
-is($stdout_recv, '', 'pg_recvlogical acknowledged changes');
-
-$node_primary->safe_psql('postgres', 'CREATE DATABASE otherdb');
-
-# Wait for catchup to ensure that the new database is visible to other sessions
-# on the standby.
-$node_primary->wait_for_replay_catchup($node_standby);
-
-($result, $stdout, $stderr) = $node_standby->psql('otherdb',
-	"SELECT lsn FROM pg_logical_slot_peek_changes('behaves_ok_activeslot', NULL, NULL) ORDER BY lsn DESC LIMIT 1;"
-);
-like(
-	$stderr,
-	qr/replication slot "behaves_ok_activeslot" was not created in this database/,
-	"replaying logical slot from another database fails");
-
-##################################################
-# Test that we can subscribe on the standby with the publication
-# created on the primary.
-##################################################
-
-# Create a table on the primary
-$node_primary->safe_psql('postgres',
-	"CREATE TABLE tab_rep (a int primary key)");
-
-# Create a table (same structure) on the subscriber node
-$node_subscriber->safe_psql('postgres',
-	"CREATE TABLE tab_rep (a int primary key)");
-
-# Create a publication on the primary
-$node_primary->safe_psql('postgres',
-	"CREATE PUBLICATION tap_pub for table tab_rep");
-
-$node_primary->wait_for_replay_catchup($node_standby);
-
-# Subscribe on the standby
-my $standby_connstr = $node_standby->connstr . ' dbname=postgres';
-
-# Not using safe_psql() here as it would wait for activity on the primary
-# and we wouldn't be able to launch pg_log_standby_snapshot() on the primary
-# while waiting.
-# psql_subscriber() allows to not wait synchronously.
-$psql_subscriber{subscriber_stdin} .= qq[CREATE SUBSCRIPTION tap_sub
-     CONNECTION '$standby_connstr'
-     PUBLICATION tap_pub
-     WITH (copy_data = off);];
-$psql_subscriber{subscriber_stdin} .= "\n";
-
-$psql_subscriber{run}->pump_nb();
-
-# Log the standby snapshot to speed up the subscription creation
-$node_primary->log_standby_snapshot($node_standby, 'tap_sub');
-
-# Explicitly shut down psql instance gracefully - to avoid hangs
-# or worse on windows
-$psql_subscriber{subscriber_stdin} .= "\\q\n";
-$psql_subscriber{run}->finish;
-
-$node_subscriber->wait_for_subscription_sync($node_standby, 'tap_sub');
-
-# Insert some rows on the primary
-$node_primary->safe_psql('postgres',
-	qq[INSERT INTO tab_rep select generate_series(1,10);]);
-
-$node_primary->wait_for_replay_catchup($node_standby);
-$node_standby->wait_for_catchup('tap_sub');
-
-# Check that the subscriber can see the rows inserted in the primary
-$result =
-  $node_subscriber->safe_psql('postgres', "SELECT count(*) FROM tab_rep");
-is($result, qq(10), 'check replicated inserts after subscription on standby');
-
-# We do not need the subscription and the subscriber anymore
-$node_subscriber->safe_psql('postgres', "DROP SUBSCRIPTION tap_sub");
-$node_subscriber->stop;
-
-# Create the injection_points extension
-$node_primary->safe_psql('testdb', 'CREATE EXTENSION injection_points;');
-
-##################################################
-# Recovery conflict: Invalidate conflicting slots, including in-use slots
-# Scenario 1: hot_standby_feedback off and vacuum FULL
-#
-# In passing, ensure that replication slot stats are not removed when the
-# active slot is invalidated, and check that an error occurs when
-# attempting to alter the invalid slot.
-##################################################
-
-# One way to produce recovery conflict is to create/drop a relation and
-# launch a vacuum full on pg_class with hot_standby_feedback turned off on
-# the standby.
-reactive_slots_change_hfs_and_wait_for_xmins('behaves_ok_', 'vacuum_full_',
-	0, 1);
-
-# Ensure that replication slot stats are not empty before triggering the
-# conflict.
-$node_primary->safe_psql('testdb',
-	qq[INSERT INTO decoding_test(x,y) SELECT 100,'100';]);
-
-$node_standby->poll_query_until('testdb',
-	qq[SELECT total_txns > 0 FROM pg_stat_replication_slots WHERE slot_name = 'vacuum_full_activeslot']
-) or die "replication slot stats of vacuum_full_activeslot not updated";
-
-# This should trigger the conflict
-wait_until_vacuum_can_remove(
-	'full', 'CREATE TABLE conflict_test(x integer, y text);
-								 DROP TABLE conflict_test;', 'pg_class');
-
-# Check invalidation in the logfile and in pg_stat_database_conflicts
-check_for_invalidation('vacuum_full_', 1, 'with vacuum FULL on pg_class');
-
-# Verify reason for conflict is 'rows_removed' in pg_replication_slots
-check_slots_conflict_reason('vacuum_full_', 'rows_removed');
-
-# Attempting to alter an invalidated slot should result in an error
-($result, $stdout, $stderr) = $node_standby->psql(
-	'postgres',
-	qq[ALTER_REPLICATION_SLOT vacuum_full_inactiveslot (failover);],
-	replication => 'database');
-ok( $stderr =~
-	  /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");
-
-# Ensure that replication slot stats are not removed after invalidation.
-is( $node_standby->safe_psql(
-		'testdb',
-		qq[SELECT total_txns > 0 FROM pg_stat_replication_slots WHERE slot_name = 'vacuum_full_activeslot']
-	),
-	't',
-	'replication slot stats not removed after invalidation');
-
-$handle =
-  make_slot_active($node_standby, 'vacuum_full_', 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 access replication slot \"vacuum_full_activeslot\"");
-
-# Attempt to copy an invalidated logical replication slot
-($result, $stdout, $stderr) = $node_standby->psql(
-	'postgres',
-	qq[select pg_copy_logical_replication_slot('vacuum_full_inactiveslot', 'vacuum_full_inactiveslot_copy');],
-	replication => 'database');
-like(
-	$stderr,
-	qr/ERROR:  cannot copy invalidated replication slot "vacuum_full_inactiveslot"/,
-	"invalidated slot cannot be copied");
-
-# Set hot_standby_feedback to on
-change_hot_standby_feedback_and_wait_for_xmins(1, 1);
-
-##################################################
-# Verify that invalidated logical slots stay invalidated across a restart.
-##################################################
-$node_standby->restart;
-
-# Verify reason for conflict is retained across a restart.
-check_slots_conflict_reason('vacuum_full_', 'rows_removed');
-
-##################################################
-# Verify that invalidated logical slots do not lead to retaining WAL.
-##################################################
-
-# Get the restart_lsn from an invalidated slot
-my $restart_lsn = $node_standby->safe_psql(
-	'postgres',
-	"SELECT restart_lsn FROM pg_replication_slots
-		WHERE slot_name = 'vacuum_full_activeslot' AND conflicting;"
-);
-
-chomp($restart_lsn);
-
-# As pg_walfile_name() can not be executed on the standby,
-# get the WAL file name associated to this lsn from the primary
-my $walfile_name = $node_primary->safe_psql('postgres',
-	"SELECT pg_walfile_name('$restart_lsn')");
-
-chomp($walfile_name);
-
-# Generate some activity and switch WAL file on the primary
-$node_primary->advance_wal(1);
-$node_primary->safe_psql('postgres', "checkpoint;");
-
-# Wait for the standby to catch up
-$node_primary->wait_for_replay_catchup($node_standby);
-
-# Request a checkpoint on the standby to trigger the WAL file(s) removal
-$node_standby->safe_psql('postgres', 'checkpoint;');
-
-# Verify that the WAL file has not been retained on the standby
-my $standby_walfile = $node_standby->data_dir . '/pg_wal/' . $walfile_name;
-ok(!-f "$standby_walfile",
-	"invalidated logical slots do not lead to retaining WAL");
-
 ##################################################
 # Recovery conflict: Invalidate conflicting slots, including in-use slots
 # Scenario 2: conflict due to row removal with hot_standby_feedback off.
 ##################################################
 
+for (my $i = 0; $i < 100; $i++) {
+
 # get the position to search from in the standby logfile
 my $logstart = -s $node_standby->logfile;
 
 # One way to produce recovery conflict is to create/drop a relation and
 # launch a vacuum on pg_class with hot_standby_feedback turned off on the
 # standby.
-reactive_slots_change_hfs_and_wait_for_xmins('vacuum_full_', 'row_removal_',
+reactive_slots_change_hfs_and_wait_for_xmins('row_removal_', 'row_removal_',
 	0, 1);
 
 # This should trigger the conflict
@@ -705,6 +380,9 @@ $handle =
 check_pg_recvlogical_stderr($handle,
 	"can no longer access replication slot \"row_removal_activeslot\"");
 
+}
+my $logstart;
+
 ##################################################
 # Recovery conflict: Same as Scenario 2 but on a shared catalog table
 # Scenario 3: conflict due to row removal with hot_standby_feedback off.
@@ -841,221 +519,4 @@ check_pg_recvlogical_stderr($handle,
 # Turn hot_standby_feedback back on
 change_hot_standby_feedback_and_wait_for_xmins(1, 1);
 
-##################################################
-# Recovery conflict: Invalidate conflicting slots, including in-use slots
-# Scenario 6: incorrect wal_level on primary.
-##################################################
-
-# get the position to search from in the standby logfile
-$logstart = -s $node_standby->logfile;
-
-# drop the logical slots
-drop_logical_slots('pruning_');
-
-# create the logical slots
-create_logical_slots($node_standby, 'wal_level_');
-
-$handle =
-  make_slot_active($node_standby, 'wal_level_', 1, \$stdout, \$stderr);
-
-# reset stat: easier to check for confl_active_logicalslot in pg_stat_database_conflicts
-$node_standby->psql('testdb', q[select pg_stat_reset();]);
-
-# Make primary wal_level replica. This will trigger slot conflict.
-$node_primary->append_conf(
-	'postgresql.conf', q[
-wal_level = 'replica'
-]);
-$node_primary->restart;
-
-$node_primary->wait_for_replay_catchup($node_standby);
-
-# Check invalidation in the logfile and in pg_stat_database_conflicts
-check_for_invalidation('wal_level_', $logstart, 'due to wal_level');
-
-# Verify reason for conflict is 'wal_level_insufficient' in pg_replication_slots
-check_slots_conflict_reason('wal_level_', 'wal_level_insufficient');
-
-$handle =
-  make_slot_active($node_standby, 'wal_level_', 0, \$stdout, \$stderr);
-# We are not able to read from the slot as it requires effective_wal_level >= logical on
-# the primary server
-check_pg_recvlogical_stderr($handle,
-	"logical decoding on standby requires \"effective_wal_level\" >= \"logical\" on the primary"
-);
-
-# Restore primary wal_level
-$node_primary->append_conf(
-	'postgresql.conf', q[
-wal_level = 'logical'
-]);
-$node_primary->restart;
-$node_primary->wait_for_replay_catchup($node_standby);
-
-$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 access replication slot \"wal_level_activeslot\"");
-
-##################################################
-# DROP DATABASE should drop its slots, including active slots.
-##################################################
-
-# drop the logical slots
-drop_logical_slots('wal_level_');
-
-# create the logical slots
-create_logical_slots($node_standby, 'drop_db_');
-
-$handle = make_slot_active($node_standby, 'drop_db_', 1, \$stdout, \$stderr);
-
-# Create a slot on a database that would not be dropped. This slot should not
-# get dropped.
-$node_standby->create_logical_slot_on_standby($node_primary, 'otherslot',
-	'postgres');
-
-# dropdb on the primary to verify slots are dropped on standby
-$node_primary->safe_psql('postgres', q[DROP DATABASE testdb]);
-
-$node_primary->wait_for_replay_catchup($node_standby);
-
-is( $node_standby->safe_psql(
-		'postgres',
-		q[SELECT EXISTS(SELECT 1 FROM pg_database WHERE datname = 'testdb')]),
-	'f',
-	'database dropped on standby');
-
-check_slots_dropped('drop_db', $handle);
-
-is($node_standby->slot('otherslot')->{'slot_type'},
-	'logical', 'otherslot on standby not dropped');
-
-# Cleanup : manually drop the slot that was not dropped.
-$node_standby->psql('postgres',
-	q[SELECT pg_drop_replication_slot('otherslot')]);
-
-##################################################
-# Test standby promotion and logical decoding behavior
-# after the standby gets promoted.
-##################################################
-
-$node_standby->reload;
-
-$node_primary->psql('postgres', q[CREATE DATABASE testdb]);
-$node_primary->safe_psql('testdb',
-	qq[CREATE TABLE decoding_test(x integer, y text);]);
-
-# Wait for the standby to catchup before initializing the cascading standby
-$node_primary->wait_for_replay_catchup($node_standby);
-
-# Create a physical replication slot on the standby.
-# Keep this step after the "Verify that invalidated logical slots do not lead
-# to retaining WAL" test (as the physical slot on the standby could prevent the
-# WAL file removal).
-$node_standby->safe_psql('testdb',
-	qq[SELECT * FROM pg_create_physical_replication_slot('$standby_physical_slotname');]
-);
-
-# Initialize cascading standby node
-$node_standby->backup($backup_name);
-$node_cascading_standby->init_from_backup(
-	$node_standby, $backup_name,
-	has_streaming => 1,
-	has_restoring => 1);
-$node_cascading_standby->append_conf(
-	'postgresql.conf',
-	qq[primary_slot_name = '$standby_physical_slotname'
-	   hot_standby_feedback = on]);
-$node_cascading_standby->start;
-
-# create the logical slots
-create_logical_slots($node_standby, 'promotion_');
-
-# Wait for the cascading standby to catchup before creating the slots
-$node_standby->wait_for_replay_catchup($node_cascading_standby,
-	$node_primary);
-
-# create the logical slots on the cascading standby too
-create_logical_slots($node_cascading_standby, 'promotion_');
-
-# Make slots actives
-$handle =
-  make_slot_active($node_standby, 'promotion_', 1, \$stdout, \$stderr);
-my $cascading_handle =
-  make_slot_active($node_cascading_standby, 'promotion_', 1,
-	\$cascading_stdout, \$cascading_stderr);
-
-# Insert some rows before the promotion
-$node_primary->safe_psql('testdb',
-	qq[INSERT INTO decoding_test(x,y) SELECT s, s::text FROM generate_series(1,4) s;]
-);
-
-# Wait for both standbys to catchup
-$node_primary->wait_for_replay_catchup($node_standby);
-$node_standby->wait_for_replay_catchup($node_cascading_standby,
-	$node_primary);
-
-# promote
-$node_standby->promote;
-
-# insert some rows on promoted standby
-$node_standby->safe_psql('testdb',
-	qq[INSERT INTO decoding_test(x,y) SELECT s, s::text FROM generate_series(5,7) s;]
-);
-
-# Wait for the cascading standby to catchup
-$node_standby->wait_for_replay_catchup($node_cascading_standby);
-
-$expected = q{BEGIN
-table public.decoding_test: INSERT: x[integer]:1 y[text]:'1'
-table public.decoding_test: INSERT: x[integer]:2 y[text]:'2'
-table public.decoding_test: INSERT: x[integer]:3 y[text]:'3'
-table public.decoding_test: INSERT: x[integer]:4 y[text]:'4'
-COMMIT
-BEGIN
-table public.decoding_test: INSERT: x[integer]:5 y[text]:'5'
-table public.decoding_test: INSERT: x[integer]:6 y[text]:'6'
-table public.decoding_test: INSERT: x[integer]:7 y[text]:'7'
-COMMIT};
-
-# check that we are decoding pre and post promotion inserted rows
-$stdout_sql = $node_standby->safe_psql('testdb',
-	qq[SELECT data FROM pg_logical_slot_peek_changes('promotion_inactiveslot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');]
-);
-
-is($stdout_sql, $expected,
-	'got expected output from SQL decoding session on promoted standby');
-
-# check that we are decoding pre and post promotion inserted rows
-# with pg_recvlogical that has started before the promotion
-my $pump_timeout = IPC::Run::timer($PostgreSQL::Test::Utils::timeout_default);
-
-ok(pump_until($handle, $pump_timeout, \$stdout, qr/^.*COMMIT.*COMMIT$/s),
-	'got 2 COMMIT from pg_recvlogical output');
-
-chomp($stdout);
-is($stdout, $expected,
-	'got same expected output from pg_recvlogical decoding session');
-
-# check that we are decoding pre and post promotion inserted rows on the cascading standby
-$stdout_sql = $node_cascading_standby->safe_psql('testdb',
-	qq[SELECT data FROM pg_logical_slot_peek_changes('promotion_inactiveslot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');]
-);
-
-is($stdout_sql, $expected,
-	'got expected output from SQL decoding session on cascading standby');
-
-# check that we are decoding pre and post promotion inserted rows
-# with pg_recvlogical that has started before the promotion on the cascading standby
-ok( pump_until(
-		$cascading_handle, $pump_timeout,
-		\$cascading_stdout, qr/^.*COMMIT.*COMMIT$/s),
-	'got 2 COMMIT from pg_recvlogical output');
-
-chomp($cascading_stdout);
-is($cascading_stdout, $expected,
-	'got same expected output from pg_recvlogical decoding session on cascading standby'
-);
-
 done_testing();

Reply via email to