pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedsyslogger file descriptor question
3+ messages / 2 participants
[nested] [flat]
* syslogger file descriptor question
@ 2021-04-30 02:04 chenyanfei <postgresql_2016@163.com>
0 siblings, 0 replies; 3+ messages in thread
From: chenyanfei @ 2021-04-30 02:04 UTC (permalink / raw)
To: pgsql-bugs
When I start the postgres with -l parameter, I find the logger process
redirect to the specified log file.
The fd:1 and fd:2 point to the log file. And If we delete the file because
of the file is too big, it'll be shown as the deleted file, which cause file
descriptor leak.
When I delete the regular file, it will close the old file and reopen the
new file when rotate the log file.
Although this problem is not very serious, it has caused a lot of confusion
to our customers. So I think
if I redirect all to /dev/null whether have any problems.
--
Sent from: https://www.postgresql-archive.org/PostgreSQL-bugs-f2117394.html
^ permalink raw reply [nested|flat] 3+ messages in thread
* syslogger file descriptor question
@ 2021-04-30 02:16 chenyanfei <postgresql_2016@163.com>
2021-04-30 11:02 ` Re: syslogger file descriptor question Magnus Hagander <magnus@hagander.net>
0 siblings, 1 reply; 3+ messages in thread
From: chenyanfei @ 2021-04-30 02:16 UTC (permalink / raw)
To: pgsql-bugs
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.
--
Sent from: https://www.postgresql-archive.org/PostgreSQL-bugs-f2117394.html
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: syslogger file descriptor question
2021-04-30 02:16 syslogger file descriptor question chenyanfei <postgresql_2016@163.com>
@ 2021-04-30 11:02 ` Magnus Hagander <magnus@hagander.net>
0 siblings, 0 replies; 3+ messages in thread
From: Magnus Hagander @ 2021-04-30 11:02 UTC (permalink / raw)
To: chenyanfei <postgresql_2016@163.com>; +Cc: pgsql-bugs
On Fri, Apr 30, 2021 at 4:16 AM chenyanfei <postgresql_2016@163.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/
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2021-04-30 11:02 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-04-30 02:04 syslogger file descriptor question chenyanfei <postgresql_2016@163.com>
2021-04-30 02:16 syslogger file descriptor question chenyanfei <postgresql_2016@163.com>
2021-04-30 11:02 ` Magnus Hagander <magnus@hagander.net>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox