From 612b192cfe83cf109ec876594b45abe9fbcea20e Mon Sep 17 00:00:00 2001
From: Masahiko Sawada <sawada.mshk@gmail.com>
Date: Wed, 27 May 2026 12:17:28 -0700
Subject: [PATCH v1] Fix 051_effective_wal_level.pl on builds without injection
 points.

Commit 2af1dc89282 placed the new "logical decoding disabled after
REPACK (CONCURRENTLY)" check at the end of
051_effective_wal_level.pl. That placement assumed the logical slot
"test_slot" no longer existed when the check ran, but the assumption
only holds on builds with injection points: the earlier
injection-point-driven tests drop "test_slot" as a side effect, while
on builds without injection points the slot persists.  When
"test_slot" still exists, logical decoding remains enabled and the new
check fails on those buildfarm members.

Move the REPACK test earlier in the script, before "test_slot" is
created, so it no longer depends on slot state torn down by later
tests.

Discussion: https://postgr.es/m/CAD21AoBmdmBQ-+Jga+jSKKq5OPGEP1pEjSJfRPT6MCwVHLD6og@mail.gmail.com
---
 .../recovery/t/051_effective_wal_level.pl     | 28 +++++++++----------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/src/test/recovery/t/051_effective_wal_level.pl b/src/test/recovery/t/051_effective_wal_level.pl
index 9341e11d58a..c862073c34e 100644
--- a/src/test/recovery/t/051_effective_wal_level.pl
+++ b/src/test/recovery/t/051_effective_wal_level.pl
@@ -65,6 +65,20 @@ ok( $primary->log_contains(
 # Wait for the checkpointer to disable logical decoding.
 wait_for_logical_decoding_disabled($primary);
 
+# Test that logical decoding is disabled after repack
+$primary->safe_psql('postgres', qq[create table foo(a int primary key)]);
+$primary->safe_psql('postgres', qq[repack (concurrently) foo;]);
+ok( $primary->log_contains(
+		"logical decoding is enabled upon creating a new logical replication slot"
+	),
+	"logical decoding enabled by repack");
+
+# Wait for the checkpointer to disable logical decoding.
+wait_for_logical_decoding_disabled($primary);
+test_wal_level($primary, "replica|replica",
+	"logical decoding disabled after repack"
+);
+
 # Create a new logical slot and check that effective_wal_level must be increased
 # to 'logical'.
 $primary->safe_psql('postgres',
@@ -400,20 +414,6 @@ select pg_cancel_backend(pid) from pg_stat_activity where query ~ 'slot_canceled
 		"the activation process aborted");
 }
 
-# Test that logical decoding is disabled after repack
-$primary->safe_psql('postgres', qq[create table foo(a int primary key)]);
-$primary->safe_psql('postgres', qq[repack (concurrently) foo;]);
-ok( $primary->log_contains(
-		"logical decoding is enabled upon creating a new logical replication slot"
-	),
-	"logical decoding enabled by repack");
-
-# Wait for the checkpointer to disable logical decoding.
-wait_for_logical_decoding_disabled($primary);
-test_wal_level($primary, "replica|replica",
-	"logical decoding disabled after repack"
-);
-
 $primary->stop;
 
 done_testing();
-- 
2.54.0

