From ddaf1bf2413c6ed394900da53827045a93df8864 Mon Sep 17 00:00:00 2001
From: Fujii Masao <fujii@postgresql.org>
Date: Thu, 18 Sep 2025 19:08:35 +0900
Subject: [PATCH v1] Reduce log level for invalid primary_slot_name in
 non-postmaster processes.

Previously, when primary_slot_name was set to an invalid slot name and
the configuration file was reloaded, not only the postmaster but also
other backend processes reported a WARNING. This could result in a flood
of duplicate messages when many processes were running.

This behavior was also inconsistent with other GUC parameters,
where non-postmaster processes log such messages at DEBUG3,
so by default only the postmaster reports the message to the log.

To address this issue, this commit makes primary_slot_name follow
the same convention by reducing the log level in non-postmaster
processes from WARNING to DEBUG3.
---
 src/backend/access/transam/xlogrecovery.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c
index 346319338a0..a70a8f1e0fa 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -4761,7 +4761,8 @@ bool
 check_primary_slot_name(char **newval, void **extra, GucSource source)
 {
 	if (*newval && strcmp(*newval, "") != 0 &&
-		!ReplicationSlotValidateName(*newval, false, WARNING))
+		!ReplicationSlotValidateName(*newval, false,
+									 IsUnderPostmaster ? DEBUG3 : WARNING))
 		return false;
 
 	return true;
-- 
2.50.1

