pgsql: Avoid ERROR in recovery target GUC assign hooks

Поиск
Список
Период
Сортировка
Искать

pgsql: Avoid ERROR in recovery target GUC assign hooks

От:
Fujii Masao <fujii@postgresql.org>
Дата:
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 
Reviewed-by: Greg Lamberson 
Reviewed-by: Michael Paquier 
Reviewed-by: Scott Ray 
Reviewed-by: Álvaro Herrera 
Reviewed-by: Kyotaro Horiguchi 
Reviewed-by: Henson Choi 
Reviewed-by: Zsolt Parragi 
Reviewed-by: Fujii Masao 
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(-)

FAQ