From: | Andres Freund <andres(at)anarazel(dot)de> |
---|---|
To: | Andy Fan <zhihuifan1213(at)163(dot)com> |
Cc: | Pg Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: FullTransactionIdAdvance question |
Date: | 2024-09-20 18:17:05 |
Message-ID: | lstjexkttz7vkywlumhzqzf6altzydzfv64sbmuegg3nkkgeb5@nnkkta645abz |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
On 2024-09-20 17:38:40 +0800, Andy Fan wrote:
> static inline void
> FullTransactionIdAdvance(FullTransactionId *dest)
> {
> dest->value++;
>
> /* see FullTransactionIdAdvance() */
> if (FullTransactionIdPrecedes(*dest, FirstNormalFullTransactionId))
> return;
>
> while (XidFromFullTransactionId(*dest) < FirstNormalTransactionId)
> dest->value++;
> }
>
> I understand this functiona as: 'dest->value++' increases the epoch when
> necessary and we don't want use the TransactionId which is smaller than
> FirstNormalTransactionId. But what is the point of the below code:
>
> /* see FullTransactionIdAdvance() */
> if (FullTransactionIdPrecedes(*dest, FirstNormalFullTransactionId))
> return;
>
> It looks to me it will be never true(I added a 'Assert(false);' above
> the return, make check-world pass).
Hm. I think in the past we did have some code that could end up calling
FullTransactionIdAdvance() on special xids for some reason, IIRC it was
related to BootstrapTransactionId. Turning those into a normal xid doesn't
seem quite right, I guess and could hide bugs.
But I'm not sure it'd not better to simply assert out in those cases.
> and if it is true somehow, retruning a XID which is smaller than
> FirstNormalTransactionId looks strange as well.
Well, it'd be true if you passed it a special xid.
> IIUC, should we remove it to save a prediction on each GetNewTransactionId
> call?
I could see adding an unlikely() to make sure the compiler orders the code to
make it statically predictable.
Greetings,
Andres Freund
From | Date | Subject | |
---|---|---|---|
Next Message | Noah Misch | 2024-09-20 18:39:31 | Re: pgsql: Don't enter parallel mode when holding interrupts. |
Previous Message | Tomas Vondra | 2024-09-20 18:11:22 | Re: Why mention to Oracle ? |