Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 140A563245B for ; Fri, 10 Apr 2009 00:47:42 -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 68924-04 for ; Fri, 10 Apr 2009 00:47:40 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-qy0-f115.google.com (mail-qy0-f115.google.com [209.85.221.115]) by mail.postgresql.org (Postfix) with ESMTP id 8922B63242D for ; Fri, 10 Apr 2009 00:47:40 -0300 (ADT) Received: by qyk13 with SMTP id 13so1683414qyk.15 for ; Thu, 09 Apr 2009 20:47:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=GPn3GEJTl45up0+aj575iKgkvH2nO7PodOzSDH9zZFo=; b=cq/dhCcvmWzZb5G30flGTzPskSihmC43dbUSmSRaVR+D7Ce8LtCB9qlhTrwZfakePd c1AcyEYqHEBUczZgBD4dU6xRtxW4RRMBxeUWS+Y3/JsxwT4uzu+L5Y/nhFRcCnyjZTYG UEEilyitQqZ0+UnbBsDaVQPjSj+Y2POrujzL0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=JEdNKCIks7bK9ICXvzIqJ6qhgMklC9Auy067LZQRAfT5vL6BVO4owonDARCpgroo/H 9nW9zZeO3l4iq68IVBMNRCbHYANi7QSChgeGJ4IEeOU+RcITgGmOuQTsmMjT/cq/0bka igekWnB9J1Fq8aLDo1RZmAarZDxNy6rXhvLo4= MIME-Version: 1.0 Received: by 10.220.85.130 with SMTP id o2mr4287444vcl.80.1239335259759; Thu, 09 Apr 2009 20:47:39 -0700 (PDT) In-Reply-To: <49DDEE72.6030803@enterprisedb.com> References: <3f0b79eb0903242329j12865d55s348f5c873a956e71@mail.gmail.com> <1238064633.16568.420.camel@ebony.2ndQuadrant> <49CCBEE0.1080307@gmx.net> <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> Date: Fri, 10 Apr 2009 12:47:39 +0900 Message-ID: <3f0b79eb0904092047w355e0b3ar527a9285b161ef91@mail.gmail.com> Subject: Re: New trigger option of pg_standby From: Fujii Masao To: Heikki Linnakangas Cc: Guillaume Smet , Simon Riggs , Tom Lane , Peter Eisentraut , Kevin Grittner , pgsql-hackers Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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/539 X-Sequence-Number: 136642 Hi, On Thu, Apr 9, 2009 at 9:47 PM, Heikki Linnakangas wrote: >> + =A0 =A0 =A0 if (strspn(buf, "smart") =3D=3D 5 && strncmp(buf, "smart",= 5) =3D=3D 0) >> + =A0 =A0 =A0 { > > The strspn() call seems pointless here. OK, I'll get rid of it. > > One problem with this patch is that in smart mode, the trigger file is no= t > deleted. That's different from current pg_standby behavior, and makes > accidental failovers after one failover more likely. Yes, it's because pg_standby cannot be sure when the trigger file can be removed in smart mode. If the trigger file is deleted as soon as it's found, just like in fast mode, pg_standby may keep waiting for WAL file again. One idea to solve this problem is to tell pg_standby as a command-line argument about whether the trigger file can be removed. That parameter value can be set to 'true' when the last applied record is re-fetched. Though pg_standby is called to restore timeline history files also after that point, the trigger file is already unnecessary (pg_standby doesn't wait for history file). Specifically, if restore_command contains new % option (%e?), it's replaced by the boolean value which indicates whether the trigger file can be deleted. This value is set to 'true' when the startup process re-fetches the last valid record, 'false' otherwise. In smart mode, pg_standby determines whether to delete the trigger file according to that value. Comments? Or, do you have any better idea? Regards, --=20 Fujii Masao NIPPON TELEGRAPH AND TELEPHONE CORPORATION NTT Open Source Software Center