1
0
mirror of https://github.com/postgres/postgres.git synced 2025-10-31 10:30:33 +03:00

Make invalid primary_slot_name follow standard GUC error reporting.

Previously, if primary_slot_name was set to an invalid slot name and
the configuration file was reloaded, both the postmaster and all other
backend processes reported a WARNING. With many processes running,
this could produce a flood of duplicate messages. The problem was that
the GUC check hook for primary_slot_name reported errors at WARNING
level via ereport().

This commit changes the check hook to use GUC_check_errdetail() and
GUC_check_errhint() for error reporting. As with other GUC parameters,
this causes non-postmaster processes to log the message at DEBUG3,
so by default, only the postmaster's message appears in the log file.

Backpatch to all supported versions.

Author: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Chao Li <lic@highgo.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>
Discussion: https://postgr.es/m/CAHGQGwFud-cvthCTfusBfKHBS6Jj6kdAPTdLWKvP2qjUX6L_wA@mail.gmail.com
Backpatch-through: 13
This commit is contained in:
Fujii Masao
2025-10-22 20:10:58 +09:00
parent 9670032cc5
commit 6ff7ba9fe5
3 changed files with 66 additions and 18 deletions

View File

@@ -4760,9 +4760,20 @@ RecoveryRequiresIntParameter(const char *param_name, int currValue, int minValue
bool
check_primary_slot_name(char **newval, void **extra, GucSource source)
{
int err_code;
char *err_msg = NULL;
char *err_hint = NULL;
if (*newval && strcmp(*newval, "") != 0 &&
!ReplicationSlotValidateName(*newval, WARNING))
!ReplicationSlotValidateNameInternal(*newval, &err_code, &err_msg,
&err_hint))
{
GUC_check_errcode(err_code);
GUC_check_errdetail("%s", err_msg);
if (err_hint != NULL)
GUC_check_errhint("%s", err_hint);
return false;
}
return true;
}