Lists: | pgsql-hackers |
---|
From: | Teodor Sigaev <teodor(at)sigaev(dot)ru> |
---|---|
To: | Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Wraparound limits |
Date: | 2014-08-07 10:34:47 |
Message-ID: | 53E35647.3040404@sigaev.ru |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Hi!
I have a questions about setting transaction's wraparound limits. Function
SetTransactionIdLimit() in access/transam/varsup.c:
1)
xidWrapLimit = oldest_datfrozenxid + (MaxTransactionId >> 1);
if (xidWrapLimit < FirstNormalTransactionId)
xidWrapLimit += FirstNormalTransactionId;
Isn't it a problem if oldest_datfrozenxid > MaxTransactionId/2?
2)
xidStopLimit = xidWrapLimit - 1000000;
if (xidStopLimit < FirstNormalTransactionId)
xidStopLimit -= FirstNormalTransactionId;
xidWarnLimit = xidStopLimit - 10000000;
if (xidWarnLimit < FirstNormalTransactionId)
xidWarnLimit -= FirstNormalTransactionId;
Why does it use '-' instead of '+' if variable < FirstNormalTransactionId? In
this case it is easy to get xidStopLimit > xidWrapLimit or xidWarnLimit >
xidStopLimit...
Thank you.
--
Teodor Sigaev E-mail: teodor(at)sigaev(dot)ru
WWW: http://www.sigaev.ru/
From: | Heikki Linnakangas <hlinnakangas(at)vmware(dot)com> |
---|---|
To: | Teodor Sigaev <teodor(at)sigaev(dot)ru>, Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Wraparound limits |
Date: | 2014-08-07 13:06:22 |
Message-ID: | 53E379CE.6080108@vmware.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On 08/07/2014 01:34 PM, Teodor Sigaev wrote:
> Hi!
>
> I have a questions about setting transaction's wraparound limits. Function
> SetTransactionIdLimit() in access/transam/varsup.c:
>
> 1)
> xidWrapLimit = oldest_datfrozenxid + (MaxTransactionId >> 1);
> if (xidWrapLimit < FirstNormalTransactionId)
> xidWrapLimit += FirstNormalTransactionId;
>
> Isn't it a problem if oldest_datfrozenxid > MaxTransactionId/2?
Don't think so. What problem do you see?
> 2)
> xidStopLimit = xidWrapLimit - 1000000;
> if (xidStopLimit < FirstNormalTransactionId)
> xidStopLimit -= FirstNormalTransactionId;
>
> xidWarnLimit = xidStopLimit - 10000000;
> if (xidWarnLimit < FirstNormalTransactionId)
> xidWarnLimit -= FirstNormalTransactionId;
>
> Why does it use '-' instead of '+' if variable < FirstNormalTransactionId? In
> this case it is easy to get xidStopLimit > xidWrapLimit or xidWarnLimit >
> xidStopLimit...
Remember that the limits are compared with xids using wrap-around aware
functions TransactionIdPrecedes and TransactionidFollows. Not regular <
and >. The "<" checks above are just to check if the XID hit one of the
special TransactionIds, and if so, increase/decrese it to get back to
the normal range.
- Heikki