From: | Magnus Hagander <magnus(at)hagander(dot)net> |
---|---|
To: | chenyanfei <postgresql_2016(at)163(dot)com> |
Cc: | pgsql-bugs <pgsql-bugs(at)postgresql(dot)org> |
Subject: | Re: syslogger file descriptor question |
Date: | 2021-04-30 11:02:44 |
Message-ID: | CABUevEythzzb=YbHcUbbxuhNQs_DoHsk+PzCkuLF03_OXD7zLg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
On Fri, Apr 30, 2021 at 4:16 AM chenyanfei <postgresql_2016(at)163(dot)com> wrote:
>
> When use the pg_ctl start -l command to start the postgres, I find the
> syslogger process point to the specified log file.
>
>
> With long time running, the log file is too big. So we delete it, but the fd
> is show as deleted.
>
>
> It looks like the file descriptor leak. Although this problem has little
> impact, it brings troubles to customers.
> The regular file has the rotate mechanism, so it can close the old fd and
> reopen the new file.
>
> My question is if I specify them to /dev/null whether have any problem. I
> find one process do this not in first start.
pg_ctl just redirects what comes at stderr, and doesn't in itself
handle rotation that's correct. There are basically two ways to handle
that for you I think:
1. Enable the PostgreSQL logging collector, that is set
logging_collector='on' in your postgresql.conf. That way, only the
startup logging will go to the pg_ctl logfile, which will never grow
large. The main logging will go to the log as specified in the
PostgreSQL logging configuration.
2. Don't remove the large log file to clear it out, instead use
something like "cat /dev/null > logfile". That way the existing file
descriptors remain working, and new logging data will go into the
file. If you're using logrotate, that's the "copytruncate" option (and
what for example debian does in it's packaging).
Or a combination of the two.
--
Magnus Hagander
Me: https://www.hagander.net/
Work: https://www.redpill-linpro.com/
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2021-04-30 17:56:11 | Re: BUG #16908: Postgres (12) allows you (re)-attach partitions that violate Foreign Key constraints? |
Previous Message | Bharath Rupireddy | 2021-04-30 09:33:55 | Re: BUG #16989: parameter track_commit_timestamp's category problem |