Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 63CEB9FBC36 for ; Thu, 31 May 2007 12:10:08 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 70081-02 for ; Thu, 31 May 2007 12:09:57 -0300 (ADT) X-Greylist: delayed 10:11:22.13218 by SQLgrey-1.7.5 Received: from out2.smtp.messagingengine.com (out2.smtp.messagingengine.com [66.111.4.26]) by postgresql.org (Postfix) with ESMTP id 8C9DB9FB8A1 for ; Thu, 31 May 2007 12:09:51 -0300 (ADT) Received: from compute1.internal (compute1.internal [10.202.2.41]) by out1.messagingengine.com (Postfix) with ESMTP id 64FEF22AD86; Thu, 31 May 2007 11:09:50 -0400 (EDT) Received: from heartbeat1.messagingengine.com ([10.202.2.160]) by compute1.internal (MEProxy); Thu, 31 May 2007 11:09:50 -0400 X-Sasl-enc: BNpcwpHKJ5xRrk1oqWIzhlHTo4ibdShxxPhr/jlfgnp0 1180624189 Received: from [62.3.213.205] (unknown [62.3.213.205]) by mail.messagingengine.com (Postfix) with ESMTP id 98D93266FA; Thu, 31 May 2007 11:09:49 -0400 (EDT) Message-ID: <465EE541.3020501@vcxz.co.uk> Date: Thu, 31 May 2007 16:09:53 +0100 From: Jon Colverson User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.3) Gecko/20070326 Thunderbird/2.0.0.0 Mnenhy/0.7.5.0 MIME-Version: 1.0 To: Tom Lane CC: pgsql-admin@postgresql.org Subject: Re: Attempt to re-archive existing WAL logs after restoring from backup References: <465BA7C5.6080400@vcxz.co.uk> <465E55F2.2020103@vcxz.co.uk> <28998.1180620113@sss.pgh.pa.us> In-Reply-To: <28998.1180620113@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200705/334 X-Sequence-Number: 25654 Thanks for your reply. Tom Lane wrote: > Jon Colverson writes: >> So, I think the problem is that exitArchiveRecovery() should be marking >> the restored log file as ".done" (or perhaps not bothering to restore >> the log file at all?). > >> This looks like a bug to me. Any thoughts? > > I don't think that will fix it. The problem is that after recovery > we try to use the rest of the last WAL segment for fresh WAL data, and > therefore need to modify the segment, and therefore need to (re) archive > it. We can't fix that by doing a forced switch to a new segment, because > that still requires writing a switch record at the right place in the > last segment. There's really no way to make this work without > abandoning the principle that the archive process should never overwrite > files. (Which is certainly not a logically *necessary* thing, but it > seems like a mighty good idea from a safety perspective.) I'm not sure this is quite right. Any log in the archive is, by definition, a complete log that will have the switch record already (because it will only have been marked for archiving after being completed). Hence I don't really understand why the last one is being copied back to pg_xlog after being used in the recovery. The long comment in exitArchiveRecovery() explains that this is to replace any existing version of the file in pg_xlog, but I think it would be just as valid to simply remove any existing version since it is definitely out of date (iff restoredFromArchive). > I believe that this situation doesn't come up in ordinary scenarios > because a WAL segment doesn't get archived until it's really filled. > I take it you are using a backup procedure that undertakes to force the > last partial segment into the archive after a postmaster shutdown. I'd No; nothing is touching the archive except for the archive_command being run by PostgreSQL. -- Jon