Skip site navigation (1) Skip section navigation (2)

Re: log_filename_prefix --> log_filename + strftime()

From: "Ed L(dot)" <pgsql(at)bluepolka(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>,Andreas Pflug <pgadmin(at)pse-consulting(dot)de>,pgsql-patches(at)postgresql(dot)org
Subject: Re: log_filename_prefix --> log_filename + strftime()
Date: 2004-08-27 22:34:07
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-patches
On Friday August 27 2004 3:49, Tom Lane wrote:
> A potential problem is what about size-driven rotation?  If the hourly
> output exceeds log_rotation_size then you'd truncate and rewrite the
> current file, which is just exactly not what you want :-(.  You could
> say that truncation occurs only at time-driven, not size-driven
> rotations, but that would effectively amount to saying that size-driven
> rotation is disabled, which I don't think I like ...

> One other thing I've been thinking of suggesting is that the
> next-rotation-target-time be rounded to an exact multiple of
> log_rotation_age.  So for example if you set log_rotation_age = 60
> minutes then rotations will happen at the top of the hour no matter
> when the postmaster was started.  The simplistic approach of doing
> this on the time_t value would mean that, say, age = 24*60 would give
> you rotations occurring at GMT midnight not local midnight, which isn't
> perfect but I'd say good enough.  Again though, the interaction with
> size-driven rotation might need more thought.

Apache's rotatelogs works this way, and includes a UTC offset option, to 
allow rotations at local midnight.

> Possibly you could fix the first issue if you did all this to the code
> and then used, say, log_filename "postgresql_%H:%M.log" with 60-minute
> rotation.  You'd normally get only logfiles named after the top of the
> hour, but in an hour with unusually heavy log output you might get some
> additional files with intermediate %M values.  Course that puts you back
> to needing a cron daemon to clean those up ...

Not that elegant, but pretty reasonable, I think.  In the normal case of 
logfiles under the maximum size, everything is cleaned up.  If you bloat, 
you have some clean-up to do, but easy enough with a cron job.  We have 
been operating ~40 clusters this way for a couple years now with a modified 
Apache rotatelogs (w/truncate option) and a cron to clean-up too-old 
logfiles.  It has pretty much eliminated our disk-full crises from DB logs.


In response to


pgsql-patches by date

Next:From: Greg Sabino MullaneDate: 2004-08-27 22:50:07
Subject: Show full path name when saving in psql
Previous:From: Tom LaneDate: 2004-08-27 21:52:24
Subject: Re: log_filename_prefix --> log_filename + strftime()

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group