Re: Re: [COMMITTERS] pgsql: Ensure age() returns a stable value rather than the latest value

From: Simon Riggs <simon(at)2ndQuadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Re: [COMMITTERS] pgsql: Ensure age() returns a stable value rather than the latest value
Date: 2012-05-12 10:37:49
Message-ID: CA+U5nM+zsingQgXHLp8iULqFDJFQ27suVhJSc7hSv3F=zUuZPg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

On 11 May 2012 19:17, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Robert Haas <robertmhaas(at)gmail(dot)com> writes:
>
> It's arguable that what we should do is "use XID if on master, capture
> ReadNewTransactionId if on slave", which would avoid any backwards
> incompatibility for the first two cases while still fixing the case that
> everybody agrees is a problem.  Simon argues that this gives a weird
> variance in the master vs slave behavior, but I'm not sure I believe
> that's an issue.  In case 2, the only way that the user can tell the
> difference between force-XID-assignment and capture-ReadNewTransactionId
> is if the transaction later does something requiring an XID, which
> cannot happen anyway on the slave.  So from here the difference in these
> behaviors seems minimal and not worth creating incompatibility in the
> first two cases for.

Case (2) is more complex than described. If we use XID always, then
the so-say stable value could change mid way through a scan when the
XID is assigned and would provide neither a stable, sensible nor a
backwards compatible response.

We can only use XID if it already exists AND age() has not yet been
executed by this transaction. Which is case (1).

Case (1) does show changed behaviour. I didn't regard that as
important because the normal use case for this is a short read only
request, so case (1) is not a typical usage of the function. Given
solving case (1) means breaking case (3), I'm not convinced it is
sensible, but as you say it would be incompatible and so I'll change
it to use XID according to my stated rule above.

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

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Simon Riggs 2012-05-12 12:25:12 pgsql: Ensure backwards compatibility for GetStableLatestTransactionId(
Previous Message Peter Eisentraut 2012-05-12 09:53:37 pgsql: Fix obsolescent C declaration syntax

Browse pgsql-hackers by date

  From Date Subject
Next Message Magnus Hagander 2012-05-12 12:18:05 Re: "pgstat wait timeout" just got a lot more common on Windows
Previous Message Simon Riggs 2012-05-12 09:37:58 External Open Standards