Re: Should we add xid_current() or a int8->xid cast?

From: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Mark Dilger <mark(dot)dilger(at)enterprisedb(dot)com>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>, Mark Dilger <hornschnorter(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: Should we add xid_current() or a int8->xid cast?
Date: 2020-04-03 02:39:04
Message-ID: CA+hUKGJZ5BwGLP1VdxCc7+2RDx7nY+zpm_RNtpgH_emnxksz0g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Apr 3, 2020 at 10:37 AM Andres Freund <andres(at)anarazel(dot)de> wrote:
> On 2020-04-02 14:26:41 -0700, Mark Dilger wrote:
> > On balance, I'd rather have xid8in and xid8out work just as Thomas has
> > it. I'm not asking for any change there. But I'm curious if the
> > whole community is on the same page regarding where this is all
> > heading.
> >
> > I'm contemplating the statement that "the goal should be to reduce
> > awareness of the 32bitness of normal xids from as many places as
> > possible", which I support, and what that means for the eventual
> > signatures of functions like pg_stat_get_activity, including:
>
> Maybe. Aiming to do things like this all-at-once just makes it less
> likely for anything to ever happen.

Agreed. Let's just keep chipping away at this stuff.

> > but otherwise there would be a transition period where some have been
> > reworked to return xid8 but others not, and users during that
> > transition period might be happier with Alvaro's suggestion of
> > treating epoch/xid as two fields in xid8in and xid8out.
>
> -countless
>
> I can only restate my point that we've had 8 byte xids exposed for many
> years. We've had very few epoch/xid values exposed. I think it'd be
> insane to now start to expose that more widely.
>
> It's just about impossible for normal users to compare xids. Once one
> wrapped around, it's just too hard/mindbending. Yes, an accompanying
> epoch makes it easier, but it still can be quite confusing.

Just by the way, any xid8 values can be sliced with ::xid, so that
should help with comparisons. I'm not keen to allow users to convert
in the other direction though, due to the hard-to-understand
interlocking requirements of modulo xids (as belaboured elsewhere).

As Mark noted, I'd left a few uses of txid_XXX stuff in other tests.
So here's a 0003 patch that upgrades all of those too, so that the
only remaining usage is in the txid.sql tests (= the tests that the
backwards compat functions still work). No change to 0001 and 0002,
other than a commit message tweak (reviewer email address change).

Attachment Content-Type Size
v9-0001-Add-SQL-type-xid8-to-expose-FullTransactionId-to-.patch application/x-patch 26.6 KB
v9-0002-Introduce-xid8_XXX-functions-to-replace-txid_XXX.patch application/x-patch 61.8 KB
v9-0003-Replace-all-txid_XXX-usage-in-tests-with-xid8_XXX.patch application/x-patch 20.9 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2020-04-03 02:40:12 Re: User Interface for WAL usage data
Previous Message Fujii Masao 2020-04-03 02:31:20 Re: BUG #16109: Postgres planning time is high across version (Expose buffer usage during planning in EXPLAIN)