From: Simon Riggs <simon@2ndQuadrant.com>
To: Robert Haas <robertmhaas@gmail.com>
Cc: Aidan Van Dyk <aidan@highrise.ca>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
Cc: pgsql-hackers@postgresql.org
Subject: Re: Sync Rep for 2011CF1
Date: Sat, 22 Jan 2011 13:31:14 +0000
Message-ID: <1295703074.1803.19835.camel@ebony> (raw)
In-Reply-To: <AANLkTikG8WMhOocX9AYsRHYPc-PgxPaG6miFDD9QH3i1@mail.gmail.com>
References: <1295127631.3282.100.camel@ebony>
<4D397FE4.2020709@enterprisedb.com>
<1295616270.1803.10799.camel@ebony>
<4D39A761.1020105@enterprisedb.com>
<1295629194.1803.11957.camel@ebony>
<AANLkTinFTZjur8gP+35eDKPGBjFRbdPmCTHT87e8r4mx@mail.gmail.com>
<AANLkTikDK-1v6FfKGMA2j9VTPjnoC4ie_+c9dR2yHS3-@mail.gmail.com>
<14761.1295633002@sss.pgh.pa.us>
<AANLkTi=s4dHGt0my6QQ2oduhdyti8++bp4-_=Pxhzn7Z@mail.gmail.com>
<AANLkTikG8WMhOocX9AYsRHYPc-PgxPaG6miFDD9QH3i1@mail.gmail.com>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: simon@2ndQuadrant.com, robertmhaas@gmail.com, aidan@highrise.ca, tgl@sss.pgh.pa.us, heikki.linnakangas@enterprisedb.com
Subject: Re: Sync Rep for 2011CF1
In-Reply-To: <1295703074.1803.19835.camel@ebony>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox