Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id A26D51337B4F for ; Sat, 22 Jan 2011 09:32:11 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 97783-06 for ; Sat, 22 Jan 2011 13:32:04 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from outmail149058.authsmtp.co.uk (outmail149058.authsmtp.co.uk [62.13.149.58]) by mail.postgresql.org (Postfix) with ESMTP id 1307D13364DE for ; Sat, 22 Jan 2011 09:32:03 -0400 (AST) Received: from mail-c187.authsmtp.com (mail-c187.authsmtp.com [62.13.128.33]) by punt12.authsmtp.com (8.14.2/8.14.2/Kp) with ESMTP id p0MDVcoP062799; Sat, 22 Jan 2011 13:31:38 GMT Received: from [192.168.0.6] (79-71-91-175.dynamic.dsl.as9105.com [79.71.91.175]) (authenticated bits=0) by mail.authsmtp.com (8.14.2/8.14.2) with ESMTP id p0MDValk053716; Sat, 22 Jan 2011 13:31:36 GMT Subject: Re: Sync Rep for 2011CF1 From: Simon Riggs To: Robert Haas Cc: Aidan Van Dyk , Tom Lane , Heikki Linnakangas , pgsql-hackers@postgresql.org In-Reply-To: References: <1295127631.3282.100.camel@ebony> <4D397FE4.2020709@enterprisedb.com> <1295616270.1803.10799.camel@ebony> <4D39A761.1020105@enterprisedb.com> <1295629194.1803.11957.camel@ebony> <14761.1295633002@sss.pgh.pa.us> Content-Type: text/plain; charset="UTF-8" Date: Sat, 22 Jan 2011 13:31:14 +0000 Message-ID: <1295703074.1803.19835.camel@ebony> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 Content-Transfer-Encoding: 7bit X-Server-Quench: efa18bd5-262b-11e0-ab46-001185d377ca X-AuthReport-Spam: If SPAM / abuse - report it at: http://www.authsmtp.com/abuse X-AuthRoute: OCdxZQATClZOTQEd DAteCiN5VAwpPBRK HVkIKg5MJUcNSQVJ NksacxtFagdbZ1hf HGQLWlVEUV57WmJ/ aAwfagxDZUtQVgR0 UU9MXVdaExpoT1wB e2p4A0UpdwBFf392 K0dgW3ZbEhEsJEd1 EBpRCG8AZzV9aWFK UF0JJQdSbQNKfx5N bwR8U3ReMCtlM3Bw LC8aFBMcBw5qYB9E RApFF18KCUgMBHZm H0lbNht2dShz X-Authentic-SMTP: 61633235383639.1000:706 X-AuthFastPath: 0 (Was 255) X-AuthVirus-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=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201101/2166 X-Sequence-Number: 180003 On Fri, 2011-01-21 at 13:32 -0500, Robert Haas wrote: > One idea might be to wait both before and after commit. If > allow_standalone_primary is off, and a commit is attempted, we check > whether there's a slave connected, and if not, wait for one to > connect. Then, we write and sync the commit WAL record. Next, we > wait for the WAL to be ack'd. Of course, the standby might disappear > between the first check and the second, but it would greatly reduce > the possibility of the master being ahead of the standby after a > crash, which might be useful for some people. I like this idea. I think it would be too invasive to make a check before we insert each WAL record, as Aidan suggests. Even if we did that, you aren't protected when a standby goes down because you'll still have written half a transaction and still be waiting. So I propose that if (!allow_standalone_primary) ConfirmSyncRepAvailable(); before PreCommit_Notify(). That puts transaction into a wait state that lasts until a sync rep standby is available. Note that it is before the actual commit, so if we decide we need to we can cancel those transactions and have them properly abort. I won't add that code yet, in case better ideas emerge. There is no support for preventing connections at startup, so I will remove that completely, now. -- Simon Riggs http://www.2ndQuadrant.com/books/ PostgreSQL Development, 24x7 Support, Training and Services