pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Support "postgres -C" with runtime-computed GUCs
Date: Thu, 16 Sep 2021 02:05:02 +0000
Message-ID: <E1mQglq-0007xB-Jw@gemulon.postgresql.org> (raw)

Support "postgres -C" with runtime-computed GUCs

Until now, the -C option of postgres was handled before a small subset
of GUCs computed at runtime are initialized, leading to incorrect
results as GUC machinery would fall back to default values for such
parameters.

For example, data_checksums could report "off" for a cluster as the
control file is not loaded yet.  Or wal_segment_size would show a
segment size at 16MB even if initdb --wal-segsize used something else.
Worse, the command would fail to properly report the recently-introduced
shared_memory, that requires to load shared_preload_libraries as these
could ask for a chunk of shared memory.

Support for runtime GUCs comes with a limitation, as the operation is
now allowed on a running server.  One notable reason for this is that
_PG_init() functions of loadable libraries are called before all
runtime-computed GUCs are initialized, and this is not guaranteed to be
safe to do on running servers.  For the case of shared_memory_size,
where we want to know how much memory would be used without allocating
it, this limitation is fine.  Another case where this will help is for
huge pages, with the introduction of a different GUC to evaluate the
amount of huge pages required for a server before starting it, without
having to allocate large chunks of memory.

This feature is controlled with a new GUC flag, and four parameters are
classified as runtime-computed as of this change:
- data_checksums
- shared_memory_size
- data_directory_mode
- wal_segment_size

Some TAP tests are added to provide some coverage here, using
data_checksums in the tests of pg_checksums.

Per discussion with Andres Freund, Justin Pryzby, Magnus Hagander and
more.

Author: Nathan Bossart
Discussion: https://postgr.es/m/F2772387-CE0F-46BF-B5F1-CC55516EB885@amazon.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/0c39c292077ef3ba987ced0dc6ea1c8f4f1e1f4b

Modified Files
--------------
doc/src/sgml/ref/postgres-ref.sgml    | 11 ++++++--
src/backend/postmaster/postmaster.c   | 50 ++++++++++++++++++++++++++++++-----
src/backend/utils/misc/guc.c          |  8 +++---
src/bin/pg_checksums/t/002_actions.pl | 22 ++++++++++++++-
src/include/utils/guc.h               |  6 +++++
5 files changed, 83 insertions(+), 14 deletions(-)



view thread (21+ messages)  latest in thread

Message-ID: <E1mQglq-0007xB-Jw@gemulon.postgresql.org>
Permalink:  ../E1mQglq-0007xB-Jw@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1mQglq-0007xB-Jw@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: michael@paquier.xyz, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Support "postgres -C" with runtime-computed GUCs
  In-Reply-To: <E1mQglq-0007xB-Jw@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 DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox