Re: log_min_messages per backend type

Andres Freund <andres@anarazel.de>

From: Andres Freund <andres@anarazel.de>
To: Euler Taveira <euler@eulerto.com>
Cc: Alvaro Herrera <alvherre@alvh.no-ip.org>, pgsql-hackers@lists.postgresql.org
Date: 2025-03-06T13:33:22Z
Lists: pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Allow log_min_messages to be set per process type

  2. Assign "backend" type earlier during process start-up

  3. Use integer backend type when exec'ing a postmaster child

  4. Sort guc_parameters.dat alphabetically by name

  5. Create a separate file listing backend types

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