Uncommented GUC in postgresql.conf.sample

Started by Daniel Gustafssonabout 2 months ago9 messages
#1Daniel Gustafsson
daniel@yesql.se
1 attachment(s)

When looking at the nearby suggestion to add deprecation comment for md5 in the
.conf.sample, I happened to notice that autovacuum_worker_slots isn't commented
out it the sample file.

AFAIK all GUCs in the sample file should be set to their defaults and left
commented out. The attached does that for autovacuum_worker_slots and adds a
trivial test to test_misc to catch it (and modifies the existing test which
would've caught it). Or is there a case for leaving uncommented?

--
Daniel Gustafsson

Attachments:

v1-0001-Make-sure-all-GUCs-in-.conf.sample-are-commented-.patchapplication/octet-stream; name=v1-0001-Make-sure-all-GUCs-in-.conf.sample-are-commented-.patch; x-unix-mode=0644Download
From 9d49d5e8c863d6c9c9c89dbdde384852100df12b Mon Sep 17 00:00:00 2001
From: Daniel Gustafsson <dgustafsson@postgresql.org>
Date: Fri, 14 Nov 2025 14:48:26 +0100
Subject: [PATCH v1] Make sure all GUCs in .conf.sample are commented out

All GUCs in postgresql.conf.sample should be set to the default
value and be commented out.  Fix one instance of an uncommented
GUC and add a test to catch future omissions.

Backpatch to 18 where autovacuum_worker_slots was added.

Author: Daniel Gustafsson <daniel@yesql.se>
Reviewed-by: tbd
Discussion: https://postgr.es/m/tbd
Backpatch-through: 18
---
 src/backend/utils/misc/postgresql.conf.sample | 2 +-
 src/test/modules/test_misc/t/003_check_guc.pl | 6 +++++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
index 08bcef50c19..bafb8459f5d 100644
--- a/src/backend/utils/misc/postgresql.conf.sample
+++ b/src/backend/utils/misc/postgresql.conf.sample
@@ -688,7 +688,7 @@
 
 #autovacuum = on			# Enable autovacuum subprocess?  'on'
 					# requires track_counts to also be on.
-autovacuum_worker_slots = 16	# autovacuum worker slots to allocate
+#autovacuum_worker_slots = 16	# autovacuum worker slots to allocate
 					# (change requires restart)
 #autovacuum_max_workers = 3		# max number of autovacuum subprocesses
 #autovacuum_naptime = 1min		# time between autovacuum runs
diff --git a/src/test/modules/test_misc/t/003_check_guc.pl b/src/test/modules/test_misc/t/003_check_guc.pl
index 5ae23192a47..713d244a815 100644
--- a/src/test/modules/test_misc/t/003_check_guc.pl
+++ b/src/test/modules/test_misc/t/003_check_guc.pl
@@ -56,7 +56,7 @@ while (my $line = <$contents>)
 	# file.
 	# - Valid configuration options are followed immediately by " = ",
 	# with one space before and after the equal sign.
-	if ($line =~ m/^#?([_[:alnum:]]+) = .*/)
+	if ($line =~ m/^#([_[:alnum:]]+) = .*/)
 	{
 		# Lower-case conversion matters for some of the GUCs.
 		my $param_name = lc($1);
@@ -69,7 +69,11 @@ while (my $line = <$contents>)
 		# Update the list of GUCs found in the sample file, for the
 		# follow-up tests.
 		push @gucs_in_file, $param_name;
+
+		next;
 	}
+	# Make sure each line starts with either a # or whitespace
+	ok(0, 'missing # in postgresql.conf.sample') if ($line =~ m/^[^#\s]/);
 }
 
 close $contents;
-- 
2.39.3 (Apple Git-146)

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Daniel Gustafsson (#1)
Re: Uncommented GUC in postgresql.conf.sample

Daniel Gustafsson <daniel@yesql.se> writes:

When looking at the nearby suggestion to add deprecation comment for md5 in the
.conf.sample, I happened to notice that autovacuum_worker_slots isn't commented
out it the sample file.

AFAIK all GUCs in the sample file should be set to their defaults and left
commented out.

Yes, that is surely a bug. It should be fixed and back-patched.

regards, tom lane

#3Bruce Momjian
bruce@momjian.us
In reply to: Tom Lane (#2)
Re: Uncommented GUC in postgresql.conf.sample

On Fri, Nov 14, 2025 at 09:44:42AM -0500, Tom Lane wrote:

Daniel Gustafsson <daniel@yesql.se> writes:

When looking at the nearby suggestion to add deprecation comment for md5 in the
.conf.sample, I happened to notice that autovacuum_worker_slots isn't commented
out it the sample file.

AFAIK all GUCs in the sample file should be set to their defaults and left
commented out.

Yes, that is surely a bug. It should be fixed and back-patched.

Yes, but again, be aware that only new initdb's will see this change.
People doing a diff against an old postgresql.conf file and a new
initdb's postgresql.conf.sample in the same major release might see this
change and think they did it.

--
Bruce Momjian <bruce@momjian.us> https://momjian.us
EDB https://enterprisedb.com

Do not let urgent matters crowd out time for investment in the future.

#4Nathan Bossart
nathandbossart@gmail.com
In reply to: Tom Lane (#2)
Re: Uncommented GUC in postgresql.conf.sample

On Fri, Nov 14, 2025 at 09:44:42AM -0500, Tom Lane wrote:

Daniel Gustafsson <daniel@yesql.se> writes:

When looking at the nearby suggestion to add deprecation comment for md5 in the
.conf.sample, I happened to notice that autovacuum_worker_slots isn't commented
out it the sample file.

AFAIK all GUCs in the sample file should be set to their defaults and left
commented out.

Yes, that is surely a bug. It should be fixed and back-patched.

That's my bad. +1 for fixing and back-patching.

--
nathan

#5Andrew Dunstan
andrew@dunslane.net
In reply to: Daniel Gustafsson (#1)
Re: Uncommented GUC in postgresql.conf.sample

On 2025-11-14 Fr 9:06 AM, Daniel Gustafsson wrote:

When looking at the nearby suggestion to add deprecation comment for md5 in the
.conf.sample, I happened to notice that autovacuum_worker_slots isn't commented
out it the sample file.

AFAIK all GUCs in the sample file should be set to their defaults and left
commented out. The attached does that for autovacuum_worker_slots and adds a
trivial test to test_misc to catch it (and modifies the existing test which
would've caught it). Or is there a case for leaving uncommented?

I don't think so.

+    # Make sure each line starts with either a # or whitespace
+    ok(0, 'missing # in postgresql.conf.sample') if ($line =~ m/^[^#\s]/);

This would probably be better written something like:

# non-blank lines must start with a # as the first non-blank character
unlike($line, qr/^\s*[^#\s]/, 'missing # in postgresql.conf.sample');

This will catch more error cases (e.g. a line that starts with spaces
and then has a non-#). Also, "ok(0,...)" is a pattern you pretty much
never want. My formulation will give better diagnostics if the test fails.

OTOH, if you want to skip a lot of ok's in the regress_log file, you can
do something like:

fail("$line missing initial # in postgresql.conf.sample") if $line =~
/^\s*[^#\s]/;

cheers

andrew

--
Andrew Dunstan
EDB:https://www.enterprisedb.com

#6Álvaro Herrera
alvherre@kurilemu.de
In reply to: Andrew Dunstan (#5)
Re: Uncommented GUC in postgresql.conf.sample

On 2025-Nov-14, Andrew Dunstan wrote:

OTOH, if you want to skip a lot of ok's in the regress_log file, you can do
something like:

fail("$line missing initial # in postgresql.conf.sample") if $line =~
/^\s*[^#\s]/;

Yeah, I'm pretty confident we don't want one "ok" per correct line in
the sample file :-)

--
Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/
"I'm always right, but sometimes I'm more right than other times."
(Linus Torvalds)
https://lore.kernel.org/git/Pine.LNX.4.58.0504150753440.7211@ppc970.osdl.org/

#7Nathan Bossart
nathandbossart@gmail.com
In reply to: Nathan Bossart (#4)
Re: Uncommented GUC in postgresql.conf.sample

On Fri, Nov 14, 2025 at 08:57:46AM -0600, Nathan Bossart wrote:

That's my bad. +1 for fixing and back-patching.

Since it's my bug, I'll go ahead and apply the fix. I'll leave the new
test to you, though (unless you'd rather me take that, too).

--
nathan

#8Nathan Bossart
nathandbossart@gmail.com
In reply to: Nathan Bossart (#7)
Re: Uncommented GUC in postgresql.conf.sample

On Fri, Nov 14, 2025 at 01:01:08PM -0600, Nathan Bossart wrote:

Since it's my bug, I'll go ahead and apply the fix.

Committed.

--
nathan

#9Daniel Gustafsson
daniel@yesql.se
In reply to: Andrew Dunstan (#5)
Re: Uncommented GUC in postgresql.conf.sample

On 14 Nov 2025, at 16:20, Andrew Dunstan <andrew@dunslane.net> wrote:

OTOH, if you want to skip a lot of ok's in the regress_log file, you can do something like:

fail("$line missing initial # in postgresql.conf.sample") if $line =~ /^\s*[^#\s]/;

Went ahead with a change along this line to keep the test log noise down.
Thanks for review!

--
Daniel Gustafsson