Skip site navigation (1) Skip section navigation (2)

Re: Bug in autovacuum.c?

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Alvaro Herrera <alvherre(at)commandprompt(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Bug in autovacuum.c?
Date: 2011-03-31 21:33:38
Message-ID: AANLkTinX2=UoEbcMYDVz5E-CiFREMUEaMgpgdria07VP@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-hackers
On Thu, Mar 31, 2011 at 4:35 PM, Bruce Momjian <bruce(at)momjian(dot)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

In response to

Responses

pgsql-hackers by date

Next:From: Bruce MomjianDate: 2011-03-31 21:59:15
Subject: Re: Bug in autovacuum.c?
Previous:From: Robert HaasDate: 2011-03-31 21:30:26
Subject: Re: cast from integer to money

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group