Re: Truncate logs by max_log_size

From: Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>
To: Kirill Gavrilov <diphantxm(at)gmail(dot)com>
Cc: "Andrey M(dot) Borodin" <x4mmm(at)yandex-team(dot)ru>, Euler Taveira <euler(at)eulerto(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Truncate logs by max_log_size
Date: 2024-10-01 23:08:43
Message-ID: 35096a36-04d4-480b-a7cd-a2d8151fb737@uni-muenster.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 01.10.24 17:46, Kirill Gavrilov wrote:
>  My apologies, attached patch should work on master branch.

Nice.

I tested the feature and it does what it is intended to.

postgres=# SHOW max_log_size;
 max_log_size
--------------
 10
(1 row)

postgres=# INSERT INTO t VALUES (1,2,3,4,5,6,7,8,9,0);
ERROR:  relation "t" does not exist
LINE 1: INSERT INTO t VALUES (1,2,3,4,5,6,7,8,9,0);

Log file:

2024-10-02 00:57:13.618 CEST [1975926] ERROR:  relation "t" does not
exist at character 13
2024-10-02 00:57:13.618 CEST [1975926] STATEMENT:  INSERT INT

A few observations:

1) You missed a const qualifier in elog.c:

elog.c: In function ‘EmitErrorReport’:
elog.c:1699:29: warning: initialization discards ‘const’ qualifier from
pointer target type [-Wdiscarded-qualifiers]
 1699 |                 char* str = debug_query_string;
      |                             ^~~~~~~~~~~~~~~~~~

2) The new parameter cannot be set within a session with SET. Is it
supposed to be like this? IMHO it would be nice to able to temporarily
set this parameter without having to reload the postgresql.conf

postgres=# SET max_log_size TO 100;
ERROR:  parameter "max_log_size" cannot be changed now

3) I personally find -1 more intuitive than 0 to disable a parameter,
but I have no strong opinion about it.

4) It still lacks documentation.

--
Jim

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2024-10-02 00:27:06 Re: Add on_error and log_verbosity options to file_fdw
Previous Message Michael Paquier 2024-10-01 22:51:06 Re: Patch: Make pg_waldump.sgml less confusing