Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 9F59763347C for ; Thu, 23 Apr 2009 04:49:21 -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 77180-09 for ; Thu, 23 Apr 2009 04:49:19 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from exprod7og124.obsmtp.com (exprod7og124.obsmtp.com [64.18.2.26]) by mail.postgresql.org (Postfix) with SMTP id 1CE39631870 for ; Thu, 23 Apr 2009 04:49:18 -0300 (ADT) Received: from source ([209.85.220.177]) by exprod7ob124.postini.com ([64.18.6.12]) with SMTP ID DSNKSfAdfbn/RGbfU+eU/geWQCGTN8oX2RZU@postini.com; Thu, 23 Apr 2009 00:49:19 PDT Received: by fxm25 with SMTP id 25so395024fxm.10 for ; Thu, 23 Apr 2009 00:49:16 -0700 (PDT) Received: by 10.103.105.1 with SMTP id h1mr417999mum.13.1240472956520; Thu, 23 Apr 2009 00:49:16 -0700 (PDT) Received: from ?80.223.212.7? (dsl-hkibrasgw2-fed4df00-7.dhcp.inet.fi [80.223.212.7]) by mx.google.com with ESMTPS id j9sm2175844mue.47.2009.04.23.00.49.14 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 23 Apr 2009 00:49:15 -0700 (PDT) Message-ID: <49F01D79.8020805@enterprisedb.com> Date: Thu, 23 Apr 2009 10:49:13 +0300 From: Heikki Linnakangas Organization: EnterpriseDB User-Agent: Mozilla-Thunderbird 2.0.0.19 (X11/20090103) MIME-Version: 1.0 To: Fujii Masao CC: Simon Riggs , Guillaume Smet , Tom Lane , Peter Eisentraut , Kevin Grittner , pgsql-hackers Subject: Re: New trigger option of pg_standby References: <3f0b79eb0903242329j12865d55s348f5c873a956e71@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> <3f0b79eb0904132241p18084914g792cb8e5ab3eebb3@mail.gmail.com> <3f0b79eb0904150101pb1c59a3ubb422867e8e6a944@mail.gmail.com> <49EE1E3F.9050307@enterprisedb.com> <3f0b79eb0904212209i7fbd8b68k71db1fef09c62751@mail.gmail.com> In-Reply-To: <3f0b79eb0904212209i7fbd8b68k71db1fef09c62751@mail.gmail.com> 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: 200904/1199 X-Sequence-Number: 137302 Fujii Masao wrote: > On Wed, Apr 22, 2009 at 4:27 AM, Heikki Linnakangas > wrote: >> Fujii Masao wrote: >>> On Tue, Apr 14, 2009 at 2:41 PM, Fujii Masao >>> wrote: >>>> I'd like to propose another simple idea; pg_standby deletes the >>>> trigger file *whenever* the nextWALfile is a timeline history file. >>>> A timeline history file is restored at the end of recovery, so it's >>>> guaranteed that the trigger file is deleted whether nextWALfile >>>> exists or not. >>>> >>>> A timeline history file is restored also at the beginning of >>>> recovery, so the accidentally remaining trigger file is deleted >>>> in early warm-standby as a side-effect of this idea. >>> Here is the revised patch as above. >>> >>> If you notice something, please feel free to comment. >> Ok, looking at this in more detail now. A couple of small things: >> >> We mustn't remove the trigger file immediately even in fast mode. As noted >> elsewhere in this thread, we have the same bug in fast mode where pg_standby >> gets stuck if you copy WAL files directly into pg_xlog. > > Yes, there is the same problem also in fast mode. But, in fast > mode, the trigger file has to be deleted immediately if it's found. > Otherwise, recovery may fail as follows. > > 1. pg_standby finds the trigger file for fast mode, and returns > non-zero without deleting the trigger file. > 2. the startup process tries to read the WAL file from pg_xlog, > but it's not found. > 3. the startup process tries to restore the last applied WAL file > using pg_standby. > 4. (Again) pg_standby finds the trigger file for fast mode, and > returns non-zero without deleting the trigger file. > 5. the startup process tries to read the last applied WAL file, > but it's not found. > (though the last applied file was of course restored before, > the restored one cannot be read here) > 6. recovery fails because the last applied WAL file cannot be > read. > > On the other hand, if pg_standby returns 0 also in fast mode > when the requested file and trigger file exist, ISTM that there > is not much difference between fast and smart mode; also in > fast mode, all the available WAL files would be applied. Hmm, pg_standby could truncate the trigger file, so that it acts like a smart trigger in the subsequent pg_standby invocations. Assuming the postgres user has write access to it; it probably does because it can delete it, but conceivably it has only read access on the file but write access on the directory it's in. This is getting complicated, though. I guess it would be enough to document that you mustn't copy any extra files into pg_xlog if you use a fast trigger. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com