Re: log_truncate_on_rotation=on is not truncating - Mailing list pgsql-bugs

From Tom Lane
Subject Re: log_truncate_on_rotation=on is not truncating
Date
Msg-id 767.1342414417@sss.pgh.pa.us
Whole thread Raw
In response to Re: log_truncate_on_rotation=on is not truncating  (Viswanatham Kiran Kumar <viswanatham.kirankumar@huawei.com>)
Responses Re: log_truncate_on_rotation=on is not truncating  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
[ just got around to looking at this bug report, sorry for the delay ]

Viswanatham Kiran Kumar <viswanatham.kirankumar@huawei.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

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #6733: All Tables Empty After pg_upgrade (PG 9.2.0 beta 2)
Next
From: Tom Lane
Date:
Subject: Re: log_truncate_on_rotation=on is not truncating