From bf2b3abcaefc5ff28e2830ea08b17d3233f7d494 Mon Sep 17 00:00:00 2001
From: Stepan Neretin <slpmcf@gmail.com>
Date: Tue, 17 Nov 2026 00:52:37 +0700
Subject: [PATCH 2/2] Add TAP test for primary shutdown end of streaming FATAL

Verify that stopping the primary does not make the standby walreceiver
FATAL with could not send end of streaming message.
---
 .../t/061_primary_shutdown_streaming.pl       | 32 +++++++++++++++++++
 1 file changed, 32 insertions(+)
 create mode 100644 src/test/recovery/t/061_primary_shutdown_streaming.pl

diff --git a/src/test/recovery/t/061_primary_shutdown_streaming.pl b/src/test/recovery/t/061_primary_shutdown_streaming.pl
new file mode 100644
index 00000000000..ec8748a4f30
--- /dev/null
+++ b/src/test/recovery/t/061_primary_shutdown_streaming.pl
@@ -0,0 +1,32 @@
+# Copyright (c) 2026, PostgreSQL Global Development Group
+
+# After primary shutdown, walreceiver must not FATAL with
+# "could not send end-of-streaming message".
+
+use strict;
+use warnings FATAL => 'all';
+
+use PostgreSQL::Test::Cluster;
+use Test::More;
+
+my $node_primary = PostgreSQL::Test::Cluster->new('primary');
+$node_primary->init(allows_streaming => 1);
+$node_primary->start;
+$node_primary->backup('backup');
+
+my $node_standby = PostgreSQL::Test::Cluster->new('standby');
+$node_standby->init_from_backup($node_primary, 'backup', has_streaming => 1);
+$node_standby->start;
+
+$node_primary->wait_for_catchup($node_standby);
+
+my $log_offset = -s $node_standby->logfile;
+$node_primary->stop;
+
+ok(!$node_standby->log_contains(
+	'could not send end-of-streaming message', $log_offset),
+  'walreceiver survives primary shutdown');
+
+$node_standby->stop;
+
+done_testing();
-- 
2.56.0

