Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 801CB9FA5C8 for ; Thu, 31 May 2007 11:01:59 -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 18223-01 for ; Thu, 31 May 2007 11:01:49 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 73CDA9FB6FE for ; Thu, 31 May 2007 11:01:55 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.1/8.14.1) with ESMTP id l4VE1r8Y028999; Thu, 31 May 2007 10:01:53 -0400 (EDT) To: Jon Colverson cc: pgsql-admin@postgresql.org Subject: Re: Attempt to re-archive existing WAL logs after restoring from backup In-reply-to: <465E55F2.2020103@vcxz.co.uk> References: <465BA7C5.6080400@vcxz.co.uk> <465E55F2.2020103@vcxz.co.uk> Comments: In-reply-to Jon Colverson message dated "Thu, 31 May 2007 05:58:26 +0100" Date: Thu, 31 May 2007 10:01:53 -0400 Message-ID: <28998.1180620113@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200705/329 X-Sequence-Number: 25649 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 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 recommend not doing it that way --- instead, if you want a deterministic time that the backup is good up to, don't stop the postmaster at all, just apply pg_switch_xlog() and let the regular archiving process archive the thereby-completed segment file. regards, tom lane