Skip site navigation (1) Skip section navigation (2)

Re: Snapshot synchronization, again...

From: Florian Pflug <fgp(at)phlo(dot)org>
To: Joachim Wieland <joe(at)mcknight(dot)de>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Snapshot synchronization, again...
Date: 2011-01-07 13:47:55
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
On Jan7, 2011, at 12:41 , Joachim Wieland wrote:
> On Thu, Dec 30, 2010 at 7:31 AM, Joachim Wieland <joe(at)mcknight(dot)de> wrote:
> These are the implementation details and restrictions of the patch:
> The exporting transaction
>    - should be read-only (to discourage people from expecting that writes of
>      the exporting transaction can be seen by the importing transaction)

That seems overly strict. Wouldn't a warning about this in the docs suffice?

>    - must not be a subtransaction (we don't add subxips of our own transaction
>      to the snapshot, so importing the snapshot later would result in missing
>      subxips)

If that is necessary, wouldn't a sub-transaction that was sub-committed before
exporting the snapshot also pose a problem? The snapshot wouldn't include
the sub-transaction's xid, so once the exporting transaction has committed any
importing transaction would suddenly see the sub-transaction's changes.

>    - adds its own xid (if any) to the xip-array

Per the previous paragraph, I believe it should also add the xid's of all
non-aborted sub-transactions to the subxip-array, overflowing the array if

> The importing transaction
>    - will not import a snapshot of the same backend (even though it would
>      probably work)
>    - will not import a snapshot of a different database in the cluster
>    - should be isolation level serializable
>    - must not be a subtransaction (can we completely rollback on
> subxact-rollback?)

Sounds fine so far.

>    - leaves curcid as is, otherwise effects of previous commands would get lost
>      and magically appear later when curcid increases
>    - applies xmin, xmax, xip, subxip values of the exported snapshot to
>      GetActiveSnapshot() and GetTransactionSnapshot()
>    - takes itself out of the xip array
>    - updates MyProc->xmin but sets it only backwards but not forwards

Change a snapshot mid-transaction like that seems risky. I'd suggest to simply
decree that an importing transaction must be read-only and must not yet have set
its snapshot. So effectively, the only allowed calling sequence would be

set transaction isolation level serializable read only;

best regards,
Florian Pflug

In response to

pgsql-hackers by date

Next:From: Robert HaasDate: 2011-01-07 13:56:03
Subject: Re: DISCARD ALL ; stored procedures
Previous:From: Itagaki TakahiroDate: 2011-01-07 13:47:37
Subject: Re: [COMMITTERS] pgsql: New system view pg_stat_replication displays activity of wal sen

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group