Re: BUG #7890: wrong behaviour using pg_rotate_logfile() with parameter log_truncate_on_rotation = on - Mailing list pgsql-bugs

From Rafael Martinez
Subject Re: BUG #7890: wrong behaviour using pg_rotate_logfile() with parameter log_truncate_on_rotation = on
Date
Msg-id 51235ADF.3090109@usit.uio.no
Whole thread Raw
In response to Re: BUG #7890: wrong behaviour using pg_rotate_logfile() with parameter log_truncate_on_rotation = on  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: BUG #7890: wrong behaviour using pg_rotate_logfile() with parameter log_truncate_on_rotation = on  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 02/19/2013 11:21 AM, Tom Lane wrote:
> Rafael Martinez <r.m.guerrero@usit.uio.no> writes:
>> If the behavior we are talking about is intentional, why do be
>> have pg_rotate_logfile() if we can not manually override with
>> this function log_rotation_age and log_rotation_size?
>
> It works fine as long as the filename pattern is such that a new
> file would be selected.
>
> If we didn't have this filter, then a rotation operation would wipe
> out *current* log entries, even those that were made a millisecond
> ago. That can't possibly be a good idea.  Any rotation scheme ought
> to provide for recent entries to survive at least until you've
> rotated through whichever other log files you have.
>
> regards, tom lane

Well, postgreSQL is versatile enough to allow you to decide many
aspects of log rotation. It should be the user who decide what will
happen with log data after and during a rotation.

I agree that using a filename pattern such that a new file would be
selected is a god idea, but it is not the only way of doing this and
it should not be the only way.

What if the user wants to use the same log file name all the time, not
archive old data and not to have a log file that grows indefinitely?
This should be a valid option because it is a valid and used scenario
when administrating databases.

What if we want/need to truncate the log file before postgres has to
change the file name according to the log_filename definition?

If the alternative to not lose some log entries while we are rotating
the log file, it is to stop postgres, truncate the log file manually
and start postgres again, I prefer to lose some log entries.

This should not be a problem as long as this is documented and the
user decides to do it this way. And you still have the option of not
losing any entries and archive the old file if you want. But one thing
should not prevent the other.

regards,
- --
 Rafael Martinez Guerrero
 Center for Information Technology
 University of Oslo, Norway

 PGP Public Key: http://folk.uio.no/rafael/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)

iEYEARECAAYFAlEjWt4ACgkQBhuKQurGihTIpQCeJcOmKfnFDMqYllW2YUsywKVl
BxgAoIF+R14GNlvNLNSgxR0lUDDQN23M
=zrAw
-----END PGP SIGNATURE-----

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #7890: wrong behaviour using pg_rotate_logfile() with parameter log_truncate_on_rotation = on
Next
From: Tom Lane
Date:
Subject: Re: BUG #7890: wrong behaviour using pg_rotate_logfile() with parameter log_truncate_on_rotation = on