On Fri, May 06, 2022 at 10:13:18AM -0700, Nathan Bossart wrote: > On Tue, Apr 26, 2022 at 10:34:06AM +0900, Michael Paquier wrote: >> Yes, the redirection issue would apply to all the run-time GUCs. > > Should this be tracked as an open item for v15? There was another recent > report about the extra log output [0].
That makes it for two complaints on two separate threads. So an open item seems adapted to adjust this behavior. I have looked at the patch posted at [1], and I don't quite understand why you need the extra dance with log_min_messages. Why don't you just set the GUC at the end of the code path in PostmasterMain() where we print non-runtime-computed parameters? I am not really worrying about users deciding to set log_min_messages to PANIC in postgresql.conf when it comes to postgres -C, TBH, as they'd miss the FATAL messages if the command is attempted on a server already starting. Per se the attached. [1]: https://www.postgresql.org/message-id/20220328173503.GA137769@nathanxps13 -- Michael
From 3b8a7f8079955cd59a5a318adf6938cdd3c29c6b Mon Sep 17 00:00:00 2001 From: Michael Paquier <mich...@paquier.xyz> Date: Mon, 9 May 2022 15:50:19 +0900 Subject: [PATCH v4] Silence extra logging with 'postgres -C'. Presently, the server may emit a variety of extra log messages when inspecting GUC values. For example, when inspecting a runtime-computed GUC, the server will always emit a "database system is shut down" LOG (unless the user has set log_min_messages higher than LOG). To avoid these extra log messages, this change sets log_min_messages to FATAL when -C is used (even if set to PANIC in postgresql.conf). At FATAL, the user will still receive messages explaining why a GUC's value cannot be inspected. --- src/backend/postmaster/postmaster.c | 10 ++++++++++ doc/src/sgml/runtime.sgml | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index ce4007bb2c..38b63bc215 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -913,6 +913,16 @@ PostmasterMain(int argc, char *argv[]) puts(config_val ? config_val : ""); ExitPostmaster(0); } + + /* + * A runtime-computed GUC will be printed later on. As we initialize + * a server startup sequence, silence any log messages that may show up + * in the output generated. FATAL and more severe messages are useful + * to show, even if one would only expect at least PANIC. LOG entries + * are hidden. + */ + SetConfigOption("log_min_messages", "FATAL", PGC_INTERNAL, + PGC_S_OVERRIDE); } /* Verify that DataDir looks reasonable */ diff --git a/doc/src/sgml/runtime.sgml b/doc/src/sgml/runtime.sgml index 4465c876b1..62cec614d3 100644 --- a/doc/src/sgml/runtime.sgml +++ b/doc/src/sgml/runtime.sgml @@ -1448,7 +1448,7 @@ export PG_OOM_ADJUST_VALUE=0 server must be shut down to view this runtime-computed parameter. This might look like: <programlisting> -$ <userinput>postgres -D $PGDATA -C shared_memory_size_in_huge_pages 2> /dev/null</userinput> +$ <userinput>postgres -D $PGDATA -C shared_memory_size_in_huge_pages</userinput> 3170 $ <userinput>grep ^Hugepagesize /proc/meminfo</userinput> Hugepagesize: 2048 kB -- 2.36.0
signature.asc
Description: PGP signature