-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 02/19/2013 10:54 AM, Tom Lane wrote: > sari.thi...@usit.uio.no writes: >> ==> * this checks if the new file name is different from the old >> one. In my case it is still the same name and so the new log >> lines will be appended to the current file, not truncated like I >> expected. I think this is the wrong behaviour, what do you >> think? > > No, that behavior is intentional. Otherwise you'd lose log data > earlier than the configuration specifies. > > regards, tom lane > >
Hei Tom Well, the "problem" is there even with log_rotation_age = 0 and log_rotation_size = 0. 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? When rotating log files you can control 3 things, and they define or should define different aspects of the rotation: 1) When to rotate - ------------------- When to rotate the log file can be defined to happen automatically by log_rotation_age and/or log_rotation_size, or it can be done manually by pg_rotate_logfile(). 2) Name of the log file - ------------------------ The name of the log file can be: - - always the same - - always different - - can be defined so it will be recycled after a while. 3) Use truncation or not when creating a log file. - -------------------------------------------------- This is or should be independent of 1) and 2). It only defines if the log file we are going to start using will start from scratch or not if it already exists regardless of the log file name. This is how we see log rotation in a logical way. Actual behavior - --------------- The actual behavior of log rotation in postgreSQL does not follow this logic and in our humble opinion it is inconsistent and not clear. Truncation only works if: - - The old and new log file names are different. - - A new file is being opened due to time-based rotation, not during size-based rotation. Log rotation is in general done so the active log file does not grow indefinitely. PostgreSQL is versatile enough to allow you to activate or not truncation. If truncation is activated, it should work independently of when we rotate, how we activate the rotation and the name of the log file. We are almost there, the actual behavior can be fixed without a lot of work. Think about this usercase. You are using a log file name that does not change over time (i.e. postgreSQL.log) and you want to rotate this file so it does not grow indefinitely (you activate log_truncate_on_rotation). Then you can provoke the rotation with log_rotation_age, log_rotation_size or pg_rotate_logfile(). This does not work nowadays. The only way of rotating in this case will be to stop postgres, delete/rename the log file and start postgres again. What you do with an old file after a rotation is another question. Here PostgreSQL is versatile enough to let you define the name of the log file in many ways so you can control if the number of "old" files grow indefinitely or not. Thanks for your time. 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) iEYEARECAAYFAlEjUNkACgkQBhuKQurGihQh5gCfcAmF6h1WAfcicvHx5jCeEdWO zpIAn3Vjf1DLdAY4jaaZWqyOCBxKmll/ =5dRj -----END PGP SIGNATURE----- -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs