--- a/src/test/recovery/t/061_barrier_blocked_client.pl
+++ b/src/test/recovery/t/061_barrier_blocked_client.pl
@@ -23,17 +23,25 @@
 $standby->init_from_backup($primary, 'backup', has_streaming => 1);
 $standby->start;
 
-# A client that stops reading.  psql fetches the result in chunks and blocks
-# writing to a pipe that we never read, so the backend fills its socket
-# buffer and blocks in ClientWrite.
+# With a logical slot on the standby, promotion keeps logical decoding enabled
+# and waits for every process to absorb a barrier.  Without one it doesn't
+# wait at all.
+$primary->safe_psql('postgres',
+	"SELECT pg_create_logical_replication_slot('primary_slot', 'test_decoding')");
+$primary->wait_for_replay_catchup($standby);
+$standby->create_logical_slot_on_standby($primary, 'standby_slot', 'postgres');
+
+# A client that stops reading.  psql writes the COPY data to a pipe that we
+# never read and blocks, so the backend fills its socket buffer and blocks in
+# ClientWrite.  (Not a FETCH_COUNT query: before v17 psql runs that through a
+# cursor, and the backend goes idle between fetches.)
 my ($in, $out, $err) = ('', '', '');
 my $writer = IPC::Run::start(
 	[
 		'psql', '--no-psqlrc',
-		'--set' => 'FETCH_COUNT=100',
 		'--dbname' => $standby->connstr('postgres'),
 		'--command' =>
-		  "SELECT repeat('x', 1000) FROM generate_series(1, 1000000)"
+		  "COPY (SELECT repeat('x', 1000) FROM generate_series(1, 1000000)) TO STDOUT"
 	],
 	'<' => \$in,
 	'>' => \$out,
@@ -43,7 +51,6 @@
 	"SELECT count(*) = 1 FROM pg_stat_activity WHERE wait_event = 'ClientWrite'"
 ) or die "timed out waiting for a backend to block in ClientWrite";
 
-# Promotion waits for every process to absorb a barrier.
 my $promoted = $standby->safe_psql('postgres',
 	"SELECT pg_promote(true, $PostgreSQL::Test::Utils::timeout_default)");
 is($promoted, 't', 'promotion completes with a backend blocked on a write');
@@ -73,7 +80,9 @@
 	'postgres', 'DROP DATABASE dropme',
 	timeout => $PostgreSQL::Test::Utils::timeout_default,
 	timed_out => \$timed_out);
-is($ret, 0, 'DROP DATABASE completes with a backend blocked on a read');
+# Check timed_out too: before v17, psql() returns 0 when it times out.
+ok(!$timed_out && $ret == 0,
+	'DROP DATABASE completes with a backend blocked on a read');
 
 $reader->kill_kill;
 
