Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U7dbg-00039y-R3 for pgsql-bugs@arkaria.postgresql.org; Tue, 19 Feb 2013 03:11:00 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1U7dbf-0001sC-M8 for pgsql-bugs@arkaria.postgresql.org; Tue, 19 Feb 2013 03:10:59 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U7dbd-0001rI-Qf for pgsql-bugs@postgresql.org; Tue, 19 Feb 2013 03:10:57 +0000 Received: from szxga01-in.huawei.com ([119.145.14.64]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U7dbZ-0002ps-7Y for pgsql-bugs@postgresql.org; Tue, 19 Feb 2013 03:10:57 +0000 Received: from 172.24.2.119 (EHLO szxeml207-edg.china.huawei.com) ([172.24.2.119]) by szxrg01-dlp.huawei.com (MOS 4.3.4-GA FastPath queued) with ESMTP id AXU16685; Tue, 19 Feb 2013 11:10:45 +0800 (CST) Received: from SZXEML462-HUB.china.huawei.com (10.82.67.205) by szxeml207-edg.china.huawei.com (172.24.2.56) with Microsoft SMTP Server (TLS) id 14.1.323.7; Tue, 19 Feb 2013 11:10:09 +0800 Received: from blrprnc09ns (10.18.96.98) by szxeml462-hub.china.huawei.com (10.82.67.205) with Microsoft SMTP Server id 14.1.323.7; Tue, 19 Feb 2013 11:10:08 +0800 From: Amit Kapila To: "'Rafael Martinez'" CC: , References: <00a201ce0de5$fc2f1920$f48d4b60$@kapila@huawei.com> <51224180.6030500@usit.uio.no> In-Reply-To: <51224180.6030500@usit.uio.no> Subject: Re: BUG #7890: wrong behaviour using pg_rotate_logfile() with parameter log_truncate_on_rotation = on Date: Tue, 19 Feb 2013 08:40:07 +0530 Message-ID: <002701ce0e4e$9f454cc0$ddcfe640$@kapila@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: Ac4N6GIdWhRgmI17TC2/AtHJWpMdDQAZIVJg Content-Language: en-us X-Originating-IP: [10.18.96.98] X-CFilter-Loop: Reflected X-Pg-Spam-Score: -3.8 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org On Monday, February 18, 2013 8:28 PM Rafael Martinez wrote: > On 02/18/2013 03:41 PM, Amit Kapila wrote: > [...........] > > Why you think this is wrong behavior, do you expect any time you > > call pg_rotate_logfile(), it should truncate the file if > > log_truncate_on_rotation is on? I think if you are expecting such > > behavior, it might not be right expectation, because it considers > > the the time and log_filename format as well. > > >=20 > Hello >=20 > I agree with Sari in this report. >=20 > If you call pg_rotate_logfile() AND log_truncate_on_rotation is on, > the logfile should be truncated. This should happen even if the > logfile name does not change during rotation, and even if > log_rotation_age / log_rotation_size are defined. >=20 > According to the documentation: >=20 > "log_truncate_on_rotation ... When logging_collector is enabled, this > parameter will cause PostgreSQL to truncate (overwrite), rather than > append to, any existing log file of the same name ..." Further description for log_truncate_on_rotation is as follows: However, truncation will occur only when a new file is being opened due to = time-based rotation, not during server startup or size-based rotation. For example, using this setting in combination with a log_filename like pos= tgresql-%H.log would result in generating twenty-four hourly log files and = then cyclically overwriting them. This parameter can only be set in the pos= tgresql.conf file or on the server command line.=20 Example: To keep 7 days of logs, one log file per day named server_log.Mon,= server_log.Tue, etc, and automatically overwrite last week's log with this= week's log, set log_filename to server_log.%a, log_truncate_on_rotation to= on, and log_rotation_age to 1440. In the examples, it is clearly shown that, truncation will not happen only = on based of log_truncate_on_rotation. > "... pg_rotate_logfile signals the log-file manager to switch to a new > output file immediately" By reading the description of pg_rotate_logfile, it can mean that this is f= unction to achieve what you are saying. But as per code, it is not so. By the way, why you want this function to behave in such a way, that it can= override the meaning of other log parameters? With Regards, Amit Kapila. --=20 Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs