diff --git a/src/bin/pg_upgrade/t/003_logical_slots.pl b/src/bin/pg_upgrade/t/003_logical_slots.pl
index af9f350431..c7fecc03bd 100644
--- a/src/bin/pg_upgrade/t/003_logical_slots.pl
+++ b/src/bin/pg_upgrade/t/003_logical_slots.pl
@@ -22,7 +22,34 @@ $oldpub->init(allows_streaming => 'logical');
 my $newpub = PostgreSQL::Test::Cluster->new('newpub');
 $newpub->init(allows_streaming => 'logical');
 
-# Setup a common pg_upgrade command to be used by all the test cases
+# ------------------------------
+# TEST: Confirm max_slot_wal_keep_size must not be overwritten
+
+# pg_upgrade will fail because the GUC max_slot_wal_keep_size is overwritten
+# to a positive value
+command_checks_all(
+	[
+		'pg_upgrade', '--no-sync',
+		'-d', $oldpub->data_dir,
+		'-D', $newpub->data_dir,
+		'-b', $oldpub->config_data('--bindir'),
+		'-B', $newpub->config_data('--bindir'),
+		'-s', $newpub->host,
+		'-p', $oldpub->port,
+		'-P', $newpub->port,
+		$mode, '-o " -c max_slot_wal_keep_size=1MB"'
+	],
+	1,
+	[
+		qr/could not connect to source postmaster started with the command/
+	],
+	[qr//],
+	'run of pg_upgrade where max_slot_wal_keep_size is overwritten.'
+);
+ok( -d $newpub->data_dir . "/pg_upgrade_output.d",
+	"pg_upgrade_output.d/ not removed after pg_upgrade failure");
+
+# Setup a common pg_upgrade command to be used by upcoming test cases
 my @pg_upgrade_cmd = (
 	'pg_upgrade', '--no-sync',
 	'-d', $oldpub->data_dir,
@@ -62,8 +89,6 @@ command_checks_all(
 	[qr//],
 	'run of pg_upgrade where the new cluster has insufficient max_replication_slots'
 );
-ok( -d $newpub->data_dir . "/pg_upgrade_output.d",
-	"pg_upgrade_output.d/ not removed after pg_upgrade failure");
 
 # Set 'max_replication_slots' to match the number of slots (2) present on the
 # old cluster. Both slots will be used for subsequent tests.
