agora inbox for pgsql-committers@postgresql.org  
help / color / mirror / Atom feed
From: Fujii Masao <fujii@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Avoid ERROR in recovery target GUC assign hooks
Date: Mon, 20 Jul 2026 12:43:19 +0000
Message-ID: <E1wlnL5-000000001k2-1d8z@gemulon.postgresql.org> (raw)

Avoid ERROR in recovery target GUC assign hooks

Recovery target parameters are postmaster-startup GUCs, but their
assign hooks previously did more than assign individual parameter
values. They also updated the global recoveryTarget state and raised
ERROR if more than one recovery target appeared to be set.

This was not a good fit for GUC assign hooks. Assign hooks should not
throw ERROR, and deriving cross-parameter state while individual GUCs
are still being assigned makes the result depend on assignment order
rather than the final configuration.

For example, setting one recovery target and then setting another
recovery_target_* parameter to an empty string could clear
recoveryTarget, causing recovery to proceed with no target even
though a valid target remained configured.

Fix this by having the assign hooks only store their own parameter
values. The effective recoveryTarget is now derived once from the
final recovery_target* settings in
validateRecoveryParameters(), which also rejects configurations that
specify more than one recovery target with FATAL. This preserves the
expected behavior for repeated assignments of the same GUC, treats empty
values as "not set", and removes cross-GUC validation from the assign
hooks.

Author: JoongHyuk Shin <sjh910805@gmail.com>
Reviewed-by: Greg Lamberson <greg@lamco.io>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Scott Ray <scott@scottray.io>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Reviewed-by: Henson Choi <assam258@gmail.com>
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/CACSdjfPUa4UvKjADgOERXoxNYmCg2mqqiqKkiJk6mX6E4qgVFw@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/d5751c33cc3e842b20dbe67545fd2c850be8fa59

Modified Files
--------------
src/backend/access/transam/xlogrecovery.c   | 140 ++++++++++------------------
src/backend/utils/misc/guc_parameters.dat   |   5 +-
src/backend/utils/misc/guc_tables.c         |   1 -
src/include/access/xlogrecovery.h           |   2 +-
src/include/utils/guc_hooks.h               |   3 -
src/test/recovery/t/003_recovery_targets.pl | 123 ++++++++++++++++++------
6 files changed, 145 insertions(+), 129 deletions(-)



Message-ID: <E1wlnL5-000000001k2-1d8z@gemulon.postgresql.org>
Permalink:  ../E1wlnL5-000000001k2-1d8z@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1wlnL5-000000001k2-1d8z@gemulon.postgresql.org

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: fujii@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Avoid ERROR in recovery target GUC assign hooks
  In-Reply-To: <E1wlnL5-000000001k2-1d8z@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox