Re: age(xid) on hot standby

From: Simon Riggs <simon(at)2ndQuadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: age(xid) on hot standby
Date: 2012-01-18 20:37:31
Message-ID: CA+U5nM+3zo_FmprLCCVwhcgZhmCiwyhsfvAYwwSAvrnNe70t0w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Jan 18, 2012 at 7:55 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
>> On mån, 2012-01-16 at 22:59 -0300, Alvaro Herrera wrote:
>>> So who's going to work on a patch?  Peter, are you?  If not, we should
>>> add it to the TODO list.
>
>> Not at this very moment, but maybe in a few weeks.
>
> BTW, it strikes me that maybe the coding should work about like this:
>
>        if (!TransactionIdIsValid(age_reference_xid))
>        {
>                age_reference_xid = GetTopTransactionIdIfAny();
>                if (!TransactionIdIsValid(age_reference_xid))
>                        age_reference_xid = ReadNewTransactionId();
>        }
>        ... use age_reference_xid to compute result ...
>
> and of course code somewhere to reset age_reference_xid at end of xact.
>
> The advantage of this is
>
> (1) same code works on master and standby
>
> (2) calling age() no longer requires an otherwise read-only transaction
> to acquire an XID.

Nice solution.

Also it illustrates that some users write code that tries to do things
on a Hot Standby that are supposed to be illegal.

If the OPs error message had returned the correct SQLCODE then it
would have been better able to handle the message.

I think we should apply the patch to return the correct SQLCODE in all
cases, even if its supposedly not possible.

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jignesh Shah 2012-01-18 20:50:35 Re: [WIP] Double-write with Fast Checksums
Previous Message Alvaro Herrera 2012-01-18 20:18:31 Re: foreign key locks, 2nd attempt