Re: Truncate logs by max_log_size

From: Kirill Gavrilov <diphantxm(at)gmail(dot)com>
To: Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>
Cc: Kirill Reshke <reshkekirill(at)gmail(dot)com>, "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-11-29 20:57:38
Message-ID: CA+E0NR6MJfE8Hkk2Q-MgWUkk=Yy_4fWdiiaAKW_Ux_hcAAtAFQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Nov 29, 2024 at 10:12 PM Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>
wrote:

>
>
> On 29.11.24 12:05, Kirill Gavrilov wrote:
> > Setting max_log_size to 0 already disables truncation.
> > I changed guc units to bytes, just to make it more human-friendly.
> > Did some refactoring and fixed all warnings. Set default value in
> > postgresql.conf.
>
> Nice. The patch applies cleanly and the warnings are gone.
>
> A few other things:
>
> IMHO the documentation can be a bit clearer. It says to input the values
> in bytes, but the default value is in megabytes.
>
> + If greater than zero, each query logged is truncated to this
> many bytes.
> + Zero disables the setting.
> + Default value is 5MB.
>
> Perhaps something like "If this value is specified without units, it is
> taken as bytes." (see wal_keep_size)
>

Added to documentation. I hope it's clear now.

>
> And a pedantic note: This hint suggests that you can use TB as unit ..
>
> postgres=# set max_log_size = '1foo';
> ERROR: invalid value for parameter "max_log_size": "1foo"
> HINT: Valid units for this parameter are "B", "kB", "MB", "GB", and "TB".
>
> .. but it can never be used, as it exceeds the integer range:
>
> postgres=# SET max_log_size = '1TB';
> ERROR: invalid value for parameter "max_log_size": "1TB"
> HINT: Value exceeds integer range.
>
> Thanks
>
> --
> Jim
>

Same thing applies to log_parameter_max_length, for example.

postgres=# set log_parameter_max_length = '1foo';
ERROR: invalid value for parameter "log_parameter_max_length": "1foo"
HINT: Valid units for this parameter are "B", "kB", "MB", "GB", and "TB".
postgres=# set log_parameter_max_length = '1TB';
ERROR: invalid value for parameter "log_parameter_max_length": "1TB"
HINT: Value exceeds integer range.

I think we can leave it as is.

Attachment Content-Type Size
V5-0001-parameter-max_log_size-to-truncate-logs.patch application/octet-stream 9.0 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dean Rasheed 2024-11-29 21:01:03 Re: Added prosupport function for estimating numeric generate_series rows
Previous Message Noah Misch 2024-11-29 20:39:37 Re: Potential ABI breakage in upcoming minor releases