Re: Batch replication ordering (was Re: [GENERAL] 32/64-bit - Mailing list pgsql-general

From Stephan Szabo
Subject Re: Batch replication ordering (was Re: [GENERAL] 32/64-bit
Date
Msg-id 20030411170619.C2141-100000@megazone23.bigpanda.com
Whole thread Raw
In response to Re: Batch replication ordering (was Re: [GENERAL] 32/64-bit  ("Ed L." <pgsql@bluepolka.net>)
Responses Re: Batch replication ordering (was Re: [GENERAL] 32/64-bit  ("Ed L." <pgsql@bluepolka.net>)
Re: Batch replication ordering (was Re: [GENERAL] 32/64-bit  (Steven Singer <ssinger@navtechinc.com>)
List pgsql-general
On Fri, 11 Apr 2003, Ed L. wrote:

> For those of you who do see the validity in batching multiple transactions,
> my question is restated here:
>
> My question:  Is there an ordering algorithm that would make a consistent
> but limited batchsize replication possible?  I propose one below.
>
> Suppose you have a replication queue on the master, with dbmirror-like
> trigger-based insertions, that looks something like this:
>
>         create table replication_queue (
>                 xid     integer,
>                 seqid   serial primary key,
>                 data...
>         );
>
> Here, 'xid' is the transaction ID, 'seqid' is the queue insertion order, and
> 'data' has all the info needed to replicate the update.  Every row
> update/delete/inserte results in a row in this queue, and a transaction may
> consist of one to many rows in the queue.

> The algorithm I'm considering right now is the following:
>
>         select xid, max(seqid) as "max_seqid"
>         into temp replication_order
>         from replication_queue
>         group by xid
>         order by max(seqid)
>         limit N;
>
> Then, to get the actual queue replication order,
>
>         select q.xid, q.seqid, q.data
>         from replication_queue q, replication_order o
>         where q.xid = o.xid
>         order by o.max_seqid, q.seqid;
>
> [This is a batched variation of dbmirror's original algorithm.]
>
> So, replication is done by transaction groupings, in ascending order
> according to the maximum seqid in each transaction.  I'm hoping someone can
> poke holes in this algorithm if they exist.

Does it matter if transactions that do not affect each other are committed
on the slave in a different order than they were on the master?  I don't
think that's guaranteed by the above (unless the inserts into
replication_queue were deferred to transaction end), but I'm also
uncertain if it's a constraint you're concerned with.


pgsql-general by date:

Previous
From: "Ed L."
Date:
Subject: Re: Batch replication ordering (was Re: [GENERAL] 32/64-bit
Next
From: "Ed L."
Date:
Subject: Re: Batch replication ordering (was Re: [GENERAL] 32/64-bit