Hi,
On Sun, 7 Sept 2025 at 10:15, Fabrice Chapuis <fabrice636...@gmail.com> wrote: > Thanks for your reply Zhijie, > > I understand that the error invalid value for parameter will be diplayed > in case of bad value for the GUC synchronized_standby_slots or if a > standby node configured is not up and running. > But the problem I noticed is that statements could not execute normally > and error code is returned to the applcation. > This append after an upgrade from PG 14 to PG 17. > I could try to reproduce the issue > > > STATEMENT: select service_period,sp1_0.address_line_1 from tbl1 where > http://sp1_0.vn=$1 order by sp1_0.start_of_period > >> > 2025-08-24 13:14:29.417 CEST [848477]: [1-1] >> user=,db=,client=,application= ERROR: invalid value for parameter >> "synchronized_standby_slots": "node1,node2" >> > 2025-08-24 13:14:29.417 CEST [848477]: [2-1] >> user=,db=,client=,application= DETAIL: replication slot "s029054a" does >> not exist >> > 2025-08-24 13:14:29.417 CEST [848477]: [3-1] >> user=,db=,client=,application= CONTEXT: while setting parameter >> "synchronized_standby_slots" to "node1,node2" >> > 2025-08-24 13:14:29.418 CEST [777453]: [48-1] >> user=,db=,client=,application= LOG: background worker "parallel worker" >> (PID 848476) exited with exit code 1 >> > 2025-08-24 13:14:29.418 CEST [777453]: [49-1] >> user=,db=,client=,application= LOG: background worker "parallel worker" >> (PID 848477) exited with exit code 1 >> > >> > Is this issue already observed >> > Recently we also hit this problem. I think in a current state check_synchronized_standby_slots() and validate_sync_standby_slots() functions are not very useful: - When the hook is executed from postmaster it only checks that synchronized_standby_slots contains a valid list, but doesn't check that replication slots exists, because MyProc is NULL. It happens both, on start and on reload. - When executed from other backends set_config_with_handle() is called with elevel = 0, and therefore elevel becomes DEBUG3, which results in no useful error/warning messages. There are a couple of places where check_synchronized_standby_slots() failure is not ignored: 1. alter system set synchronized_standby_slots='invalid value'; 2. Parallel workers, because RestoreGUCState() calls set_config_option_ext()->set_config_with_handle() with elevel=ERROR. As a result, parallel workers fail to start with the error. With parallel workers it is actually even worse - we get the error even in case of standby: 1. start standby with synchronized_standby_slots referring to non-existing slots 2. SET parallel_setup_cost, parallel_tuple_cost, and min_parallel_table_scan_size to 0 3. Run select * from pg_namespace; and observe following error: ERROR: invalid value for parameter "synchronized_standby_slots": "a1,b1" DETAIL: replication slot "a1" does not exist CONTEXT: while setting parameter "synchronized_standby_slots" to "a1,b1" parallel worker We may argue a lot that invalid configuration must not be used, but the thing is that the main problem being solved by synchronized_standby_slots is delaying logical decoding at certains LSN until it was sent to enough physical standby. This feature must not affect normal queries, only logical replication. Please find attached patch fixing a problem for parallel workers. Regards, -- Alexander Kukushkin
From d4dbac3669d96d40d56fe5e738da9a78a3fcfb47 Mon Sep 17 00:00:00 2001 From: Alexander Kukushkin <cyberd...@gmail.com> Date: Mon, 8 Sep 2025 11:16:54 +0200 Subject: [PATCH] Exclude parallel workers when validating synchronized_standby_slots If synchronized_standby_slots value is invalid parallel workers fail to start with the following error: ERROR: invalid value for parameter "synchronized_standby_slots": "a1,b1" DETAIL: replication slot "a1" does not exist CONTEXT: while setting parameter "synchronized_standby_slots" to "a1,b1" Since the value can't be properly validated from postmaster process we shouldn't fail in parallel workers either. --- src/backend/replication/slot.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/backend/replication/slot.c b/src/backend/replication/slot.c index a234e2ca9c1..76ce7a35a01 100644 --- a/src/backend/replication/slot.c +++ b/src/backend/replication/slot.c @@ -39,6 +39,7 @@ #include <unistd.h> #include <sys/stat.h> +#include "access/parallel.h" #include "access/transam.h" #include "access/xlog_internal.h" #include "access/xlogrecovery.h" @@ -2441,7 +2442,7 @@ validate_sync_standby_slots(char *rawname, List **elemlist) { GUC_check_errdetail("List syntax is invalid."); } - else if (MyProc) + else if (MyProc && !IsParallelWorker()) { /* * Check that each specified slot exist and is physical. -- 2.34.1