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

With the -= change to =, we get:

        xidForceLimit   Result
        ---------------------------
        max_xid-2       max_xid-2
        max_xid-1       max_xid-1
        max_xid         max_xid
        0               3
        1               3
        2               3
        3               3

-- 
  Bruce Momjian  <br...@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + It's impossible for everything to be true. +

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to