From 1d175bbeef3ab83e5c992a648e22c7c1cd3c671f Mon Sep 17 00:00:00 2001
From: Robert Haas <rhaas@postgresql.org>
Date: Tue, 14 Nov 2023 13:49:28 -0500
Subject: [PATCH v11 7/7] Test patch: Enable summarize_wal by default.

To avoid test failures, must remove the prohibition against running
summarize_wal=off with wal_level=minimal, because a bunch of tests
run with wal_level=minimal.

Not for commit.
---
 src/backend/postmaster/postmaster.c                 | 3 ---
 src/backend/postmaster/walsummarizer.c              | 2 +-
 src/backend/utils/misc/guc_tables.c                 | 2 +-
 src/test/recovery/t/001_stream_rep.pl               | 2 ++
 src/test/recovery/t/019_replslot_limit.pl           | 3 +++
 src/test/recovery/t/020_archive_status.pl           | 1 +
 src/test/recovery/t/035_standby_logical_decoding.pl | 1 +
 7 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c
index 7952fd5c4b..a804d07ce5 100644
--- a/src/backend/postmaster/postmaster.c
+++ b/src/backend/postmaster/postmaster.c
@@ -935,9 +935,6 @@ PostmasterMain(int argc, char *argv[])
 	if (max_wal_senders > 0 && wal_level == WAL_LEVEL_MINIMAL)
 		ereport(ERROR,
 				(errmsg("WAL streaming (max_wal_senders > 0) requires wal_level \"replica\" or \"logical\"")));
-	if (summarize_wal && wal_level == WAL_LEVEL_MINIMAL)
-		ereport(ERROR,
-				(errmsg("WAL cannot be summarized when wal_level is \"minimal\"")));
 
 	/*
 	 * Other one-time internal sanity checks can go here, if they are fast.
diff --git a/src/backend/postmaster/walsummarizer.c b/src/backend/postmaster/walsummarizer.c
index 7966755f22..74a0116a13 100644
--- a/src/backend/postmaster/walsummarizer.c
+++ b/src/backend/postmaster/walsummarizer.c
@@ -139,7 +139,7 @@ static XLogRecPtr redo_pointer_at_last_summary_removal = InvalidXLogRecPtr;
 /*
  * GUC parameters
  */
-bool		summarize_wal = false;
+bool		summarize_wal = true;
 int			wal_summary_keep_time = 10 * 24 * 60;
 
 static XLogRecPtr GetLatestLSN(TimeLineID *tli);
diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c
index a6de5aca0a..170f491d7a 100644
--- a/src/backend/utils/misc/guc_tables.c
+++ b/src/backend/utils/misc/guc_tables.c
@@ -1796,7 +1796,7 @@ struct config_bool ConfigureNamesBool[] =
 			NULL
 		},
 		&summarize_wal,
-		false,
+		true,
 		NULL, NULL, NULL
 	},
 
diff --git a/src/test/recovery/t/001_stream_rep.pl b/src/test/recovery/t/001_stream_rep.pl
index 95f9b0d772..0d0e63b8dc 100644
--- a/src/test/recovery/t/001_stream_rep.pl
+++ b/src/test/recovery/t/001_stream_rep.pl
@@ -15,6 +15,8 @@ my $node_primary = PostgreSQL::Test::Cluster->new('primary');
 $node_primary->init(
 	allows_streaming => 1,
 	auth_extra => [ '--create-role', 'repl_role' ]);
+# WAL summarization can postpone WAL recycling, leading to test failures
+$node_primary->append_conf('postgresql.conf', "summarize_wal = off");
 $node_primary->start;
 my $backup_name = 'my_backup';
 
diff --git a/src/test/recovery/t/019_replslot_limit.pl b/src/test/recovery/t/019_replslot_limit.pl
index 7d94f15778..a8b342bb98 100644
--- a/src/test/recovery/t/019_replslot_limit.pl
+++ b/src/test/recovery/t/019_replslot_limit.pl
@@ -22,6 +22,7 @@ $node_primary->append_conf(
 min_wal_size = 2MB
 max_wal_size = 4MB
 log_checkpoints = yes
+summarize_wal = off
 ));
 $node_primary->start;
 $node_primary->safe_psql('postgres',
@@ -256,6 +257,7 @@ $node_primary2->append_conf(
 min_wal_size = 32MB
 max_wal_size = 32MB
 log_checkpoints = yes
+summarize_wal = off
 ));
 $node_primary2->start;
 $node_primary2->safe_psql('postgres',
@@ -310,6 +312,7 @@ $node_primary3->append_conf(
 	max_wal_size = 2MB
 	log_checkpoints = yes
 	max_slot_wal_keep_size = 1MB
+    summarize_wal = off
 	));
 $node_primary3->start;
 $node_primary3->safe_psql('postgres',
diff --git a/src/test/recovery/t/020_archive_status.pl b/src/test/recovery/t/020_archive_status.pl
index fa24153d4b..d0d6221368 100644
--- a/src/test/recovery/t/020_archive_status.pl
+++ b/src/test/recovery/t/020_archive_status.pl
@@ -15,6 +15,7 @@ $primary->init(
 	has_archiving => 1,
 	allows_streaming => 1);
 $primary->append_conf('postgresql.conf', 'autovacuum = off');
+$primary->append_conf('postgresql.conf', 'summarize_wal = off');
 $primary->start;
 my $primary_data = $primary->data_dir;
 
diff --git a/src/test/recovery/t/035_standby_logical_decoding.pl b/src/test/recovery/t/035_standby_logical_decoding.pl
index 9c34c0d36c..482edc57a8 100644
--- a/src/test/recovery/t/035_standby_logical_decoding.pl
+++ b/src/test/recovery/t/035_standby_logical_decoding.pl
@@ -250,6 +250,7 @@ $node_primary->append_conf(
 wal_level = 'logical'
 max_replication_slots = 4
 max_wal_senders = 4
+summarize_wal = off
 });
 $node_primary->dump_info;
 $node_primary->start;
-- 
2.37.1 (Apple Git-137.1)

