Re: log_truncate_on_rotation=on is not truncating

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: viswanatham(dot)kirankumar(at)huawei(dot)com
Cc: "'Chan Pham'" <chan(dot)pham(at)iovation(dot)com>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: log_truncate_on_rotation=on is not truncating
Date: 2012-07-16 04:53:37
Message-ID: 767.1342414417@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

[ just got around to looking at this bug report, sorry for the delay ]

Viswanatham Kiran Kumar <viswanatham(dot)kirankumar(at)huawei(dot)com> 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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2012-07-16 05:43:22 Re: log_truncate_on_rotation=on is not truncating
Previous Message Tom Lane 2012-07-15 21:45:28 Re: BUG #6733: All Tables Empty After pg_upgrade (PG 9.2.0 beta 2)