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. Ed ---------------------------(end of broadcast)--------------------------- TIP 8: explain analyze is your friend