From: | vignesh C <vignesh21(at)gmail(dot)com> |
---|---|
To: | Арсений Косицын <a(dot)kositsyn(at)postgrespro(dot)ru> |
Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: [PATCH] Fixed creation of empty .log files during log rotation |
Date: | 2025-03-14 10:22:42 |
Message-ID: | CALDaNm38zE_jn0z=w9nBcEgX1tFhkYQFP9nuh9eHvp3U8gr13Q@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Tue, 29 Oct 2024 at 13:38, Арсений Косицын <a(dot)kositsyn(at)postgrespro(dot)ru> wrote:
>
>
> Hi everyone!
>
> A situation has been discovered in which empty .log files are being created.
>
> --Reproduce:
>
> 1) You need to set the following parameters in the "postgresql.conf" file:
>
> log_destination = 'csvlog'
> logging_collector = on
> log_rotation_age = 1min
> log_directory = '/home/user/builds/postgresql/log'
>
> 2) After starting the server, two files are being created in the directory with logs:
>
> -rw------- 1 user user 1,4K oct 10 13:29 postgresql-2024-10-10_132907.csv
> -rw------- 1 user user 172 oct 10 13:29 postgresql-2024-10-10_132907.log
>
> 3) The .log file is created anyway, regardless of the log_destination parameter.
> The following message is displayed in the .log file (due to the fact that the log_destination
> parameter is set = 'csvlog'):
>
> 2024-10-10 13:05:52.539 MSK [1629065] LOG: ending log output to stderr
> 2024-10-10 13:05:52.539 MSK [1629065] HINT: Future log output will go to log destination "csvlog".
>
> Next, the stderr stream is redirected to a .csv file.
>
> 4) Now, logs are rotated once a minute (due to the set log_rotation_age parameter). Moreover, all
> open log files are rotated, including the .log file that I wrote about above. New ones are being created
> .csv and .log files. Logs themselves are sent to .csv, and nothing else is output to .log
> and it remains empty:
>
> -rw------- 1 user user 1,4K oct 10 13:29 postgresql-2024-10-10_132907.csv
> -rw------- 1 user user 172 oct 10 13:29 postgresql-2024-10-10_132907.log
> -rw------- 1 user user 1,4K oct 10 13:30 postgresql-2024-10-10_133000.csv
> -rw------- 1 user user 0 oct 10 13:30 postgresql-2024-10-10_133000.log
>
> --Fix:
>
> To correct the situation, you can add a check for the "Log_destination" parameter in the "logfile_rotate()"
> function of the "syslogger.c" module. Then only the logs specified in this parameter will be rotated. This is done in the proposed patch.
Some agreed-upon comments from [1] need to be addressed. I'm changing
the status to "Waiting on Author." Please resolve the comments, submit
a V2 patch, and update the status back to "Needs Review."
[1] - https://www.postgresql.org/message-id/4dc16c9a-a546-48a6-a8df-ab7441a008a6%40postgrespro.ru
Regards,
Vignesh
From | Date | Subject | |
---|---|---|---|
Next Message | vignesh C | 2025-03-14 10:31:13 | Re: doc: Mention clock synchronization recommendation for hot_standby_feedback |
Previous Message | Yuya Watari | 2025-03-14 10:09:38 | Re: [PoC] Reducing planning time when tables have many partitions |