Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id C1093632335 for ; Thu, 15 Jan 2009 10:25:44 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 14370-07 for ; Thu, 15 Jan 2009 10:25:40 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from exprod7og110.obsmtp.com (exprod7og110.obsmtp.com [64.18.2.173]) by mail.postgresql.org (Postfix) with SMTP id 3D26C632332 for ; Thu, 15 Jan 2009 10:25:35 -0400 (AST) Received: from source ([209.85.219.21]) by exprod7ob110.postini.com ([64.18.6.12]) with SMTP ID DSNKSW9HXq+PYNuJy6K3DA0NwpRg5GwlmNDU@postini.com; Thu, 15 Jan 2009 06:25:39 PST Received: by ewy14 with SMTP id 14so1276833ewy.5 for ; Thu, 15 Jan 2009 06:25:33 -0800 (PST) Received: by 10.210.88.7 with SMTP id l7mr1723749ebb.3.1232029533400; Thu, 15 Jan 2009 06:25:33 -0800 (PST) Received: from ?88.195.102.92? (dsl-hkibrasgw2-ff66c300-92.dhcp.inet.fi [88.195.102.92]) by mx.google.com with ESMTPS id k9sm76088300nfh.57.2009.01.15.06.25.31 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 15 Jan 2009 06:25:32 -0800 (PST) Message-ID: <496F4759.6060203@enterprisedb.com> Date: Thu, 15 Jan 2009 16:25:29 +0200 Organization: EnterpriseDB User-Agent: Mozilla-Thunderbird 2.0.0.17 (X11/20081018) MIME-Version: 1.0 To: Bruce Momjian CC: Fujii Masao , Randy Isbell , pgsql-bugs@postgresql.org Subject: Re: BUG #4566: pg_stop_backup() reports incorrect STOP WAL LOCATION References: <200901150150.n0F1oV113850@momjian.us> <496F2795.70105@enterprisedb.com> In-Reply-To: <496F2795.70105@enterprisedb.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit From: Heikki Linnakangas X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200901/94 X-Sequence-Number: 22076 Looking at the original post again: > The resulting *.backup file: > > START WAL LOCATION: 10/FE1E2BAC (file 0000000200000010000000FE) > STOP WAL LOCATION: 10/FF000000 (file 0000000200000010000000FF) > CHECKPOINT LOCATION: 10/FE1E2BAC > START TIME: 2008-11-09 01:15:06 CST > LABEL: /bck/db/sn200811090115.tar.gz > STOP TIME: 2008-11-09 01:15:48 CST > > In my 8.3.4 instance, WAL file naming occurs as: > > ... > 0000000100000003000000FD > 0000000100000003000000FE > 000000010000000400000000 > 000000010000000400000001 > ... > > WAL files never end in 'FF'. This causes a problem when trying to collect > the ending WAL file for backup. I can see the potential confusion here. START WAL LOCATION is an inclusive value, while STOP WAL LOCATION is exclusive. You need to archive all WAL files < STOP WAL LOCATION to have a valid backup, not <=. Printing the filenames adds to the confusion. Perhaps if we printed them like "files 0000000200000010000000FE <= X < 0000000200000010000000FF" the intention would be clearer, but we can't change the format now without braking all existing backups. In 8.4, this will be less of an issue, because pg_stop_backup() now waits for the last file to be archived before returning, so you don't have to look at those values to implement the waiting yourself. In the passing, I notice that the manual says for pg_xlog_switch(): > pg_switch_xlog moves to the next transaction log file, allowing the current file to be archived (assuming you are using continuous archiving). The result is the ending transaction log location within the just-completed transaction log file. If there has been no transaction log activity since the last transaction log switch, pg_switch_xlog does nothing and returns the end location of the previous transaction log file. That's incorrect. According comments in RequestXLogSwitch(), what it actually returns is: > * The return value is either the end+1 address of the switch record, > * or the end+1 address of the prior segment if we did not need to > * write a switch record because we are already at segment start. Note that "end+1 address of the prior segment" is the same as "first byte of the *next* segment", which contradicts with the manual. I'll change that paragraph in the manual into: The result is the ending transaction log location *+ 1* within the just-completed transaction log file. If there has been no transaction log activity since the last transaction log switch, pg_switch_xlog does nothing and returns the *start* location of the transaction log file *currently in use*. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com