Re: log_min_messages per backend type - Mailing list pgsql-hackers

From Andres Freund
Subject Re: log_min_messages per backend type
Date
Msg-id y5tgui75jrcj6mm5nmoq4yqwage2432akx4kp2ogtcnim3wskx@2ipmtfi4qvpi
Whole thread Raw
In response to Re: log_min_messages per backend type  ("Euler Taveira" <euler@eulerto.com>)
List pgsql-hackers
Hi,

On 2025-03-04 21:33:39 -0300, Euler Taveira wrote:
> +/*
> + * This must match enum BackendType! It should be static, but
> + * commands/variable.c needs to get at this.
> + */
> +int            log_min_messages[] = {
> +    [B_INVALID] = WARNING,
> +    [B_BACKEND] = WARNING,
> +    [B_DEAD_END_BACKEND] = WARNING,
> +    [B_AUTOVAC_LAUNCHER] = WARNING,
> +    [B_AUTOVAC_WORKER] = WARNING,
> +    [B_BG_WORKER] = WARNING,
> +    [B_WAL_SENDER] = WARNING,
> +    [B_SLOTSYNC_WORKER] = WARNING,
> +    [B_STANDALONE_BACKEND] = WARNING,
> +    [B_ARCHIVER] = WARNING,
> +    [B_BG_WRITER] = WARNING,
> +    [B_CHECKPOINTER] = WARNING,
> +    [B_STARTUP] = WARNING,
> +    [B_WAL_RECEIVER] = WARNING,
> +    [B_WAL_SUMMARIZER] = WARNING,
> +    [B_WAL_WRITER] = WARNING,
> +    [B_LOGGER] = WARNING,
> +};

> +StaticAssertDecl(lengthof(log_min_messages) == BACKEND_NUM_TYPES,
> +                 "array length mismatch");
> +
> +/*
> + * This must match enum BackendType! It might be in commands/variable.c but for
> + * convenience it is near log_min_messages.
> + */
> +const char *const log_min_messages_backend_types[] = {
> +    [B_INVALID] = "backend",    /* XXX same as backend? */
> +    [B_BACKEND] = "backend",
> +    [B_DEAD_END_BACKEND] = "backend",    /* XXX same as backend? */
> +    [B_AUTOVAC_LAUNCHER] = "autovacuum",
> +    [B_AUTOVAC_WORKER] = "autovacuum",
> +    [B_BG_WORKER] = "bgworker",
> +    [B_WAL_SENDER] = "walsender",
> +    [B_SLOTSYNC_WORKER] = "slotsyncworker",
> +    [B_STANDALONE_BACKEND] = "backend", /* XXX same as backend? */
> +    [B_ARCHIVER] = "archiver",
> +    [B_BG_WRITER] = "bgwriter",
> +    [B_CHECKPOINTER] = "checkpointer",
> +    [B_STARTUP] = "backend",    /* XXX same as backend? */

Huh, the startup process is among the most crucial things to monitor?

> +    [B_WAL_RECEIVER] = "walreceiver",
> +    [B_WAL_SUMMARIZER] = "walsummarizer",
> +    [B_WAL_WRITER] = "walwriter",
> +    [B_LOGGER] = "logger",
> +};
> +
> +StaticAssertDecl(lengthof(log_min_messages_backend_types) == BACKEND_NUM_TYPES,
> +                 "array length mismatch");
> +

I don't know what I think about the whole patch, but I do want to voice
*strong* opposition to duplicating a list of all backend types into multiple
places. It's already painfull enough to add a new backend type, without having
to pointlessly go around and manually add a new backend type to mulltiple
arrays that have completely predictable content.

Greetings,

Andres Freund



pgsql-hackers by date:

Previous
From: Matthias van de Meent
Date:
Subject: Re: explain analyze rows=%.0f
Next
From: Fujii Masao
Date:
Subject: Re: Add pg_accept_connections_start_time() for better uptime calculation