Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id AB7019A4AA5 for ; Mon, 16 Jul 2012 01:54:33 -0300 (ADT) Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SqdKJ-0000Ue-7k for pgsql-bugs@postgresql.org; Mon, 16 Jul 2012 04:54:33 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.5/8.14.5) with ESMTP id q6G4rbAd000768; Mon, 16 Jul 2012 00:53:37 -0400 (EDT) From: Tom Lane To: viswanatham.kirankumar@huawei.com cc: "'Chan Pham'" , pgsql-bugs@postgresql.org Subject: Re: log_truncate_on_rotation=on is not truncating In-reply-to: <009901cd4fad$4b5ff9d0$e21fed70$@kirankumar@huawei.com> References: <009901cd4fad$4b5ff9d0$e21fed70$@kirankumar@huawei.com> Comments: In-reply-to Viswanatham Kiran Kumar message dated "Thu, 21 Jun 2012 18:26:36 +0530" Date: Mon, 16 Jul 2012 00:53:37 -0400 Message-ID: <767.1342414417@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201207/116 X-Sequence-Number: 33592 [ just got around to looking at this bug report, sorry for the delay ] Viswanatham Kiran Kumar writes: > Hi Chan, > I think this is configuration issue. > This issue is happening because log files will always append when > server is restarted. What I can see from your configuration, > log_rotation_age=1d (1 day) which is greater than daily schedule > shutdown/restart time. So this is the reason why log files are growing. Yeah, I think that's part of it, but it does still seem like a bug. The relevant bit of the code is /* * The requirements here are to choose the next time > now that is a * "multiple" of the log rotation interval. "Multiple" can be interpreted * fairly loosely. In this version we align to log_timezone rather than * GMT. */ rotinterval = Log_RotationAge * SECS_PER_MINUTE; /* convert to seconds */ now = (pg_time_t) time(NULL); tm = pg_localtime(&now, log_timezone); now += tm->tm_gmtoff; now -= now % rotinterval; now += rotinterval; now -= tm->tm_gmtoff; next_rotation_time = now; Looking at this, it seems like it will choose a next_rotation_time that is more than rotinterval beyond "now" if you have a log_timezone for which advancing by gmtoff moves past the next natural rotinterval multiple. So if the server gets shut down before that time elapses, it never will think it should rotate the logfile. Chan, could you say exactly what log_timezone setting is in use on the servers that are acting funny? regards, tom lane