On 23 Aug 2016 20:10, "Kevin Grittner" <kgri...@gmail.com> wrote:
> On Mon, Aug 22, 2016 at 6:39 PM, Craig Ringer <cr...@2ndquadrant.com>
> > On 23 Aug 2016 05:43, "Kevin Grittner" <kgri...@gmail.com> wrote:
> >> On Mon, Aug 22, 2016 at 3:29 PM, Robert Haas <robertmh...@gmail.com>
> >>
> >>> it seems to me that
> >>> this is just one facet of a much more general problem: given two
> >>> transactions T1 and T2, the order of replay must match the order of
> >>> commit unless you can prove that there are no dependencies between
> >>> them.  I don't see why it matters whether the operations are sequence
> >>> operations or data operations; it's just a question of whether they're
> >>> modifying the same "stuff".
> >> The commit order is the simplest and safest *unless* there is a
> >> read-write anti-dependency a/k/a read-write dependency a/k/a
> >> rw-conflict: where a read from one transaction sees the "before"
> >> version of data modified by the other transaction.  In such a case
> >> it is necessary for correct serializable transaction behavior for
> >> the transaction that read the "before" image to be replayed before
> >> the write it didn't see, regardless of commit order.  If you're not
> >> trying to avoid serialization anomalies, it is less clear to me
> >> what is best.
> >
> > Could you provide an example of a case where xacts replayed in
> > commit order will produce incorrect results?
> https://wiki.postgresql.org/wiki/SSI#Deposit_Report
> ... where T3 is on the replication target.

Right. But we don't attempt to replicate locking let alone SSI state. As I
said this is expected. If T1, T2 and T3 run in the master in either READ
COMMITTED or SERIALIZABLE we will correctly replay whatever got committed
and leave the replica in the same state as the master.

It is row level replication so there is no simple way to detect this
anomaly. We would have to send a lot of co-ordination data *in both
directions*, right?

Sounds like a job for tightly coupled clustering with a GTM, GLM etc. We're
a very very long way from that.

The docs probably need to be fairly explicit about the guarantees made and
not made and how behavior of queries on replicas can differ from queries on
master. The same is true for physical replication though, right?

Good point that xacts run on replicas can differ in results from the same
query on master though. At least in read only SERIALIZABLE xacts which are
effectively downgraded to REPEATABLE READ (snapshot) with respect to xacts
on master. But continue to get full SSI with respect to other (possibly
r/w) xacts on the replica. We can't really just disallow SERIALIZABLE
isolation xacts because they remain useful. But we might want to be able to
at least warn if they touch replicated (subscriber) tables.

Reply via email to