Re: Reducing the log spam

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>
Cc: Jelte Fennema-Nio <postgres(at)jeltef(dot)nl>, Isaac Morland <isaac(dot)morland(at)gmail(dot)com>, Justin Pryzby <pryzby(at)telsasoft(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Reducing the log spam
Date: 2025-03-11 09:46:26
Message-ID: 9baf5d621fc7f07faabfb74333f15d0bd2dbebac.camel@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, 2025-03-07 at 20:38 +0100, Jim Jones wrote:
> I've tested this patch and for the most part it works as intended.

Thanks for the thorough test!

> There are a few issues though ...
>
> 1) Invalid codes aren't rejected. Is there any way to validate them?
>
> postgres=# SET log_suppress_errcodes TO '0foo1'; SHOW log_suppress_errcodes;
> SET
>  log_suppress_errcodes
> -----------------------
>  0foo1
> (1 row)

That is intentional. I only test that the SQLSTATE is 5 characters long
and contains only ASCII letters and numbers. I looked at the SQL standard,
and while it defines the meaning of certain SQLSTATEs, it allows for
custom defined states.

Nothing bad can happen from setting an unused SQLSTATE; it just won't
suppress anything.

> 2) No duplication check (not critical IMO)
>
> postgres=# SET log_suppress_errcodes TO '3F000,3F000'; SHOW
> log_suppress_errcodes;
> SET
>  log_suppress_errcodes
> -----------------------
>  3F000,3F000
> (1 row)
>
>
> 3) errcodes are not trimmed (also not critical..  just doesn't look nice)
>
> postgres=# SET log_suppress_errcodes TO '               3F000, 42P01';
> SHOW log_suppress_errcodes;
> SET
>     log_suppress_errcodes    
> -----------------------------
>                 3F000, 42P01
> (1 row)

These two are mostly cosmetic issues.

I originally thought it best to leave the parameter the way the user
entered it, but in the attached version I revised that by reassembling
the parameter string from the parsed SQLSTATEs, so that spaces and
duplicates will vanish and everything is converted to upper case.

So these complaints should be addressed.

> 4) SHOW log_suppress_errcodes displays an invalid value if we set it
> twice to an empty string
>
> $ /usr/local/postgres-dev/bin/psql postgres
> psql (18devel)
> Type "help" for help.
>
> postgres=# SET log_suppress_errcodes TO ''; SHOW log_suppress_errcodes;
> SET log_suppress_errcodes TO ''; SHOW log_suppress_errcodes;
> SET
>  log_suppress_errcodes
> -----------------------
>  
> (1 row)
>
> SET
>  log_suppress_errcodes
> -----------------------
>  wV
> (1 row)
>
>
> 5) The system crashes if we set log_suppress_errcodesto an empty string
> and then set it back to comma separated values

These two points were actually caused by a memory management bug that I
had inadvertently introduced in the assign hook. They should be fixed now.

Attached is the fifth version of the patch.

Yours,
Laurenz Albe

Attachment Content-Type Size
v5-0001-Add-parameter-log_suppress_errcodes.patch text/x-patch 11.6 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bykov Ivan 2025-03-11 09:47:18 RE: Query ID Calculation Fix for DISTINCT / ORDER BY and LIMIT / OFFSET
Previous Message Anthonin Bonnefoy 2025-03-11 09:26:32 Re: Memory context can be its own parent and child in replication command