Re: Proposal for CSN based snapshots

From: Simon Riggs <simon(at)2ndQuadrant(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Simon Riggs <simon(at)2ndquadrant(dot)com>, Alexander Korotkov <a(dot)korotkov(at)postgrespro(dot)ru>, Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>, Dilip Kumar <dilipbalaut(at)gmail(dot)com>, Jeff Davis <pgsql(at)j-davis(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Greg Stark <stark(at)mit(dot)edu>, Andres Freund <andres(at)2ndquadrant(dot)com>, Rajeev rastogi <rajeev(dot)rastogi(at)huawei(dot)com>, Markus Wanner <markus(at)bluegap(dot)ch>, Ants Aasma <ants(at)cybertec(dot)at>, Bruce Momjian <bruce(at)momjian(dot)us>, obartunov <obartunov(at)postgrespro(dot)ru>, Teodor Sigaev <teodor(at)postgrespro(dot)ru>
Subject: Re: Proposal for CSN based snapshots
Date: 2015-07-25 08:39:04
Message-ID: CANP8+jLyhL92eJi7RVX_yvbKjxm9=OBKcmNnodaYmeE+o2i1+Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 24 July 2015 at 19:21, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:

> On Fri, Jul 24, 2015 at 1:00 PM, Simon Riggs <simon(at)2ndquadrant(dot)com>
> wrote:
> > It depends on the exact design we use to get that. Certainly we do not
> want
> > them if they cause a significant performance regression.
>
> Yeah. I think the performance worries expressed so far are:
>
> - Currently, if you see an XID that is between the XMIN and XMAX of
> the snapshot, you hit CLOG only on first access. After that, the
> tuple is hinted. With this approach, the hint bit doesn't avoid
> needing to hit CLOG anymore, because it's not enough to know whether
> or not the tuple committed; you have to know the CSN at which it
> committed, which means you have to look that up in CLOG (or whatever
> SLRU stores this data). Heikki mentioned adding some caching to
> ameliorate this problem, but it sounds like he was worried that the
> impact might still be significant.
>

This seems like the heart of the problem. Changing a snapshot from a list
of xids into one number is easy. Making XidInMVCCSnapshot() work is the
hard part because there needs to be a translation/lookup from CSN to
determine if it contains the xid.

That turns CSN into a reference to a cached snapshot, or a reference by
which a snapshot can be derived on demand.

> - Mixing synchronous_commit=on and synchronous_commit=off won't work
> as well, because if the LSN ordering of commit records matches the
> order in which transactions become visible, then an async-commit
> transaction can't become visible before a later sync-commit
> transaction. I expect we might just decide we can live with this, but
> it's worth discussing in case people feel otherwise.
>

Using the Commit LSN as CSN seems interesting, but it is not the only
choice.

Commit LSN is not the precise order in which commits become visible because
of the race condition between marking commit in WAL and marking commit in
clog. That problem is accentuated by mixing async and sync, but that is not
the only source of racing.

--
Simon Riggs http://www.2ndQuadrant.com/
<http://www.2ndquadrant.com/>
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2015-07-25 08:46:02 Re: optimizing vacuum truncation scans
Previous Message David G. Johnston 2015-07-25 08:33:14 proposal: multiple psql option -c