pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: viswanatham.kirankumar@huawei.com
Cc: 'Chan Pham' <chan.pham@iovation.com>
Cc: pgsql-bugs@postgresql.org
Subject: Re: log_truncate_on_rotation=on is not truncating
Date: Mon, 16 Jul 2012 01:43:22 -0400
Message-ID: <2054.1342417402@sss.pgh.pa.us> (raw)
In-Reply-To: <767.1342414417@sss.pgh.pa.us>
References: <CADnKLtYdYujf1Narz0ChL+=YuEMWxY8joungPUiDz3H+K_7+xA@mail.gmail.com>
	<009901cd4fad$4b5ff9d0$e21fed70$@kirankumar@huawei.com>
	<767.1342414417@sss.pgh.pa.us>

I wrote:
> 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.
>      */

Oh, no, scratch that --- there's nothing wrong with that calculation.
Actually I think the issue is with the logic that decides whether to
truncate or append during rotation:

     * Decide whether to overwrite or append.  We can overwrite if (a)
     * Log_truncate_on_rotation is set, (b) the rotation was triggered by
     * elapsed time and not something else, and (c) the computed file name is
     * different from what we were previously logging into.
     *
     * Note: during the first rotation after forking off from the postmaster,
     * last_file_name will be NULL.  (We don't bother to set it in the
     * postmaster because it ain't gonna work in the EXEC_BACKEND case.) So we
     * will always append in that situation, even though truncating would
     * usually be safe.

This dates from around 2004, and at the time we did not think it was
very important if the first rotation opportunity failed to truncate.
Of course, if you restart the postmaster so often that it never gets to
the second rotation opportunity, that theory falls down.  But I guess
it's worth asking why you think it's a good plan to reboot so often.
Most people running Postgres are appalled by the idea that they might
have to have any downtime at all.

			regards, tom lane



view thread (5+ messages)  latest in thread

Message-ID: <2054.1342417402@sss.pgh.pa.us>
Permalink:  ../2054.1342417402@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/2054.1342417402@sss.pgh.pa.us

 · 

reply

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-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, viswanatham.kirankumar@huawei.com, chan.pham@iovation.com
  Subject: Re: log_truncate_on_rotation=on is not truncating
  In-Reply-To: <2054.1342417402@sss.pgh.pa.us>
  References: <CADnKLtYdYujf1Narz0ChL+=YuEMWxY8joungPUiDz3H+K_7+xA@mail.gmail.com> <009901cd4fad$4b5ff9d0$e21fed70$@kirankumar@huawei.com> <767.1342414417@sss.pgh.pa.us> <2054.1342417402@sss.pgh.pa.us>

* 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