Re: Inconsistent DB data in Streaming Replication

From: Hannu Krosing <hannu(at)2ndQuadrant(dot)com>
To: Samrat Revagade <revagade(dot)samrat(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Inconsistent DB data in Streaming Replication
Date: 2013-04-09 07:42:29
Message-ID: 5163C665.40702@2ndQuadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 04/08/2013 12:34 PM, Samrat Revagade wrote:
>
> Hello,
>
> We have been trying to figure out possible solutions to the following
> problem in streaming replication Consider following scenario:
>
> If master receives commit command, it writes and flushes commit WAL
> records to the disk, It also writes and flushes data page related to
> this transaction.
>
No data page flushing takes place. All data page writing is delayed to
bgWriter and/or checkpoints.
>
> The master then sends WAL records to standby up to the commit WAL
> record. But before sending these records if failover happens then,
> old master is ahead of standby which is now the new master in terms
> of DB data leading to inconsistent data .
>
The master sends WAL records to standby continuously, not "upon commit
wal record".

In case of syncrep the master just waits for confirmation from standby
before returning to client on commit.
>
> One solution to avoid this situation is have the master send WAL
> records to standby and wait for ACK from standby committing WAL files
> to disk and only after that commit data page related to this
> transaction on master.
>
Not just commit, you must stop any *writing* of the wal records
effectively killing any parallelism.
>
> The main drawback would be increased wait time for the client due to
> extra round trip to standby before master sends ACK to client. Are
> there any other issues with this approach?
>
Min issue is that it will make *all* backends dependant on each sync
commit, essentially serialising all backends commits, with the
serialisation *including* the latency of roundtrip to client.

With current sync streaming the other backends can continue to write wal,
with proposed approach you can not write any records after the one
waiting an ACK from standby.
>
>
> Thank you,
>
> Samrat
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dimitri Fontaine 2013-04-09 08:22:20 Re: Call for Google Summer of Code mentors, admins
Previous Message Ants Aasma 2013-04-09 07:39:35 Re: Enabling Checksums