From: Laurenz Albe <laurenz.albe@cybertec.at>
To: Lesley Kimmel <lesley.j.kimmel@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: csvlog Behavior when log file missing
Date: Tue, 04 Jun 2019 08:54:16 +0200
Message-ID: <9810a29323c67938f0d895174b38b8ff45bf0a66.camel@cybertec.at> (raw)
In-Reply-To: <CAAQu=7TyW-dPN0yKX1VqZsJK=5WX=izs7oPX=2YqaL+JjQeFjQ@mail.gmail.com>
References: <CAAQu=7TyW-dPN0yKX1VqZsJK=5WX=izs7oPX=2YqaL+JjQeFjQ@mail.gmail.com>
Lesley Kimmel wrote:
> I have a system where postgres seems to be randomly dying. When researching the issue
> I, of course, began looking at logs.
>
> I found that much of the logs were missing due to logrotate configuration on the server.
> Logs were being rotated by size and then compressed. Because of this, the first rotation
> would take the log file out from underneath the database and it is not recreated.
>
> My suspicion is that the database eventually crashes due to inability to log.
> The documentation says the logging_collector will halt other processes if it is
> unable to log. However, it seems that the system continues to run fine for several
> days before crashing and applications using the database continue to operate.
>
> Does the logrotate configuration possibly explain the behavior? I can add the
> 'copytruncate' option to the logrotate configuration and see if the issue resolves,
> but I'd like to also understand the issue. Also, if I add the 'stderr' destination
> and continue to rotate the csv log file out, might I catch errors related to the
> missing csv log or would the logging_collector simply continue operating since it
> still has access to the stderr log?
To diagnose the problem, why don't you disable logrotate for a while?
Then you can see if it is part of the problem, but above all nothing will
mess with your log files and you should be able to find out more about the problem.
I never use logrotate with PostgreSQL, but set "log_filename" to "postgresql-%a.log"
or "postgresql-%d.log", "log_truncate_on_rotation" to "on" and "log_rotation_size" to
"0". Then PostgreSQL rotates the log by itself.
Yours,
Laurenz Albe
--
Cybertec | https://www.cybertec-postgresql.com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: laurenz.albe@cybertec.at, lesley.j.kimmel@gmail.com
Subject: Re: csvlog Behavior when log file missing
In-Reply-To: <9810a29323c67938f0d895174b38b8ff45bf0a66.camel@cybertec.at>
References: <CAAQu=7TyW-dPN0yKX1VqZsJK=5WX=izs7oPX=2YqaL+JjQeFjQ@mail.gmail.com> <9810a29323c67938f0d895174b38b8ff45bf0a66.camel@cybertec.at>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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