Re: Usage of epoch in txid_current

From: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
To: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
Cc: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, Andres Freund <andres(at)anarazel(dot)de>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Alexander Korotkov <a(dot)korotkov(at)postgrespro(dot)ru>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, Andrey Borodin <x4mmm(at)yandex-team(dot)ru>
Subject: Re: Usage of epoch in txid_current
Date: 2019-05-04 17:34:06
Message-ID: CAMkU=1xLb7105EaAEpSyCs7RbHPZm_nZw7qMkvJp3h4_FeZrZA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Mar 28, 2019 at 1:30 AM Thomas Munro <thomas(dot)munro(at)gmail(dot)com> wrote:

> On Thu, Mar 28, 2019 at 1:48 AM Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
> wrote:
> > Once we have the FullTransactionId type and basic macros in place, I'm
> > sure we could tidy up a bunch of code by using them.

Thanks for the reviews! Pushed.
>

I think that this might be broken.

We have this change:

@@ -73,7 +75,8 @@ GetNewTransactionId(bool isSubXact)

LWLockAcquire(XidGenLock, LW_EXCLUSIVE);

- xid = XidFromFullTransactionId(ShmemVariableCache->nextFullXid);
+ full_xid = ShmemVariableCache->nextFullXid;
+ xid = XidFromFullTransactionId(full_xid);

But then later on in an little-used code path around line 164:

/* Re-acquire lock and start over */
LWLockAcquire(XidGenLock, LW_EXCLUSIVE);
xid = XidFromFullTransactionId(ShmemVariableCache->nextFullXid);

full_xid does not get updated, but then later on full_xid gets returned in
lieu of xid.

Is there a reason that this is OK?

Cheers,

Jeff

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeff Janes 2019-05-04 17:45:18 Re: Usage of epoch in txid_current
Previous Message Arthur Zakirov 2019-05-04 16:11:21 Re: to_timestamp docs