Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hY3LB-0002WJ-1n for pgsql-general@arkaria.postgresql.org; Tue, 04 Jun 2019 06:54:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hY3L8-0007Q1-G7 for pgsql-general@arkaria.postgresql.org; Tue, 04 Jun 2019 06:54:34 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hY3L7-0007PS-RZ for pgsql-general@lists.postgresql.org; Tue, 04 Jun 2019 06:54:33 +0000 Received: from mx2.mailbox.org ([80.241.60.215]) by makus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hY3L3-000091-J0 for pgsql-general@lists.postgresql.org; Tue, 04 Jun 2019 06:54:32 +0000 Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mx2.mailbox.org (Postfix) with ESMTPS id 78071A01C5; Tue, 4 Jun 2019 08:54:24 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter06.heinlein-hosting.de (spamfilter06.heinlein-hosting.de [80.241.56.125]) (amavisd-new, port 10030) with ESMTP id V3bn797TsS4A; Tue, 4 Jun 2019 08:54:17 +0200 (CEST) Message-ID: <9810a29323c67938f0d895174b38b8ff45bf0a66.camel@cybertec.at> Subject: Re: csvlog Behavior when log file missing From: Laurenz Albe To: Lesley Kimmel , pgsql-general@lists.postgresql.org Date: Tue, 04 Jun 2019 08:54:16 +0200 In-Reply-To: References: Organization: Cybertec Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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