Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id A7F816331E7 for ; Tue, 14 Apr 2009 06:34:41 -0300 (ADT) 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 94775-07 for ; Tue, 14 Apr 2009 06:34:39 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from outmail136037.authsmtp.co.uk (outmail136037.authsmtp.co.uk [62.13.136.37]) by mail.postgresql.org (Postfix) with ESMTP id 9EFCA632C5E for ; Tue, 14 Apr 2009 06:34:39 -0300 (ADT) Received: from mail-c189.authsmtp.com (mail-c189.authsmtp.com [62.13.128.71]) by punt3.authsmtp.com (8.14.2/8.14.2/Kp) with ESMTP id n3E9YGP0037143; Tue, 14 Apr 2009 10:34:16 +0100 (BST) Received: from [192.168.0.4] (85-211-223-92.dyn.gotadsl.co.uk [85.211.223.92]) (authenticated bits=0) by mail.authsmtp.com (8.14.2/8.14.2/Kp) with ESMTP id n3E9YEAx065192; Tue, 14 Apr 2009 10:34:15 +0100 (BST) Subject: Re: New trigger option of pg_standby From: Simon Riggs To: Fujii Masao Cc: Heikki Linnakangas , Guillaume Smet , Tom Lane , Peter Eisentraut , Kevin Grittner , pgsql-hackers In-Reply-To: <3f0b79eb0904122252t1f4c5860v919d199f399ccf72@mail.gmail.com> References: <3f0b79eb0903242329j12865d55s348f5c873a956e71@mail.gmail.com> <8365.1238163943@sss.pgh.pa.us> <1238164596.16568.604.camel@ebony.2ndQuadrant> <3f0b79eb0903311901h70520cc8u9c0f1d8f4193923b@mail.gmail.com> <3f0b79eb0904022042g35b8e3cah9432ff764e721a3@mail.gmail.com> <1d4e0c10904071456m735e3f67q123b87243d2f6f2a@mail.gmail.com> <3f0b79eb0904071817u5c32254ei61f7e68e54669d9e@mail.gmail.com> <49DDEE72.6030803@enterprisedb.com> <3f0b79eb0904092047w355e0b3ar527a9285b161ef91@mail.gmail.com> <1239381103.16396.30.camel@ebony.2ndQuadrant> <3f0b79eb0904122252t1f4c5860v919d199f399ccf72@mail.gmail.com> Content-Type: text/plain Date: Tue, 14 Apr 2009 10:35:40 +0100 Message-Id: <1239701740.16396.86.camel@ebony.2ndQuadrant> Mime-Version: 1.0 X-Mailer: Evolution 2.12.0 Content-Transfer-Encoding: 7bit X-Server-Quench: 6b7ce139-28d7-11de-bc7b-001f29070be2 X-AuthRoute: OCdxZQATClZOTQEd DAteCiNZVAwpPBRK HVkIKg5MJUcNSQVJ NksacRtFaQFbbElD HGQLW11EUV17Wmd/ ag8fZQBDYEtPQQdo U1ZAQE1QEQdtHhxP WB1rW3AHBk1Gfntx bEQsXHRcXAp8J0Eu F09XHHAEbTNndWEe BBVFJVBTIh5Kfh4T aFl/U3NfNGdJBC9q VzwTFhsSEA9kHWxz Tx5FMUgTTkkGBHY7 XwwDGjNnGkNNXyoE NAAvLFIWDS41 X-Authentic-SMTP: 61633235383639.kestrel.dmpriest.net.uk:1378/Kp X-Report-SPAM: If SPAM / abuse - report it at: http://www.authsmtp.com/abuse X-Virus-Status: No virus detected - but ensure you scan with your own anti-virus system. X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200904/743 X-Sequence-Number: 136846 On Mon, 2009-04-13 at 14:52 +0900, Fujii Masao wrote: > A lookahead (the +1) may have pg_standby get stuck as follows. > Am I missing something? > > 1. the trigger file containing "smart" is created. > 2. pg_standby is executed. > 2-1. nextWALfile is restored. > 2-2. the trigger file is deleted because nextWALfile+1 doesn't exist. > 3. the restored nextWALfile is applied. > 4. pg_standby is executed again to restore nextWALfile+1. This can't happen. (4) will never occur when (2-2) has occurred. A non-zero error code means file not available which will cause recovery to end and hence no requests for further WAL files are made. It does *seem* as if there is a race condition there in that another WAL file may arrive after we have taken the decision there are no more WAL files, but it's not a problem. That could happen if we issue the trigger while the master is still up, which is a mistake - why would we do that? If we only issue the trigger once we are happy the master is down then we don't get a problem. So lets do it the next+1 way, when triggered. -- Simon Riggs www.2ndQuadrant.com PostgreSQL Training, Services and Support