On Thu, Mar 31, 2011 at 4:35 PM, Bruce Momjian <bruce@momjian.us> wrote:
> Robert Haas wrote:
>> >> > The effect is to map max xid + 1 to max xid -
>> >> > FirstNormalTransactionId(3) + 1, which makes the xid look like it is
>> >> > going backwards, less than max xid --- not good.
>> >>
>> >> The XID space is *circular*.
>> >
>> > Right but you would think that as the xid moves forward, the caculation
>> > of how far back to vacuum should move only forward. ?In this case,
>> > incrementing the xid by one would cause the vacuum horizon to move
>> > backward by two.
>>
>> I don't see how that would happen. The XID immediately preceding
>> FirstNormalTransactionId is 2^32-1, and that's exactly what this
>> calculation produces.
>
> OK, let me see if I understand --- the caculation is below:
>
> xidForceLimit = recentXid - autovacuum_freeze_max_age;
> if (xidForceLimit < FirstNormalTransactionId)
> xidForceLimit -= FirstNormalTransactionId;
>
> The values:
>
> xidForceLimit Result
> ---------------------------
> max_xid-2 max_xid-2
> max_xid-1 max_xid-1
> max_xid max_xid
> 0 max_xid-3 <- backward here
> 1 max_xid-2
> 2 max_xid-1
> 3 3
You have to consider those three lines all of a piece. Suppose
autovacuum_freeze_age is 100. Then:
105 -> 5
104 -> 4
103 -> 3
102 -> max_xid
101 -> max_xid - 1
100 -> max_xid - 2
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company