Re: xid wraparound

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: xid wraparound
Дата
Msg-id 20488.1285548179@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: xid wraparound  (Mark Rostron <mrostron@ql2.com>)
Ответы Re: xid wraparound  (Mark Rostron <mrostron@ql2.com>)
Список pgsql-admin
Mark Rostron <mrostron@ql2.com> writes:
>> No.  XID comparisons are modulo 2^31.

> Thanks - I'm still trying to wrap my mind around this (sorry).

> So, for the sake of this description:
> - the XID space (size 2^32) is split into two sub-spaces, each of size 2^31

No, it is not.  The XID space is continuous and circular.  For any given
XID, there are 2^31-1 possible XIDs that are "before" it and 2^31-1 that
are "after" it (plus the special FrozenXID value, which is always before
everything else).  There's no absolute comparisons possible, only
relative ones.  Everything works without wraparound hiccups, because the
XID space has no endpoints.  The price is that consistency is lost if
there are ever XIDs in the system that are more than 2^31 transactions
apart.  We avoid that by replacing old XIDs with FrozenXID before they
get to be more than 2^31 transactions old.

> Therefore, a query can only see rows where:
> (q.o > r.o) && (q.s == r.s) || (q.o <= r.o) && (q.s != r.s)

Actually, to compare two XIDs we just do a signed subtraction (ignoring
overflow) and see if the result is positive or negative.

            regards, tom lane

В списке pgsql-admin по дате отправления:

Предыдущее
От: Mark Rostron
Дата:
Сообщение: Re: xid wraparound
Следующее
От: Mark Rostron
Дата:
Сообщение: Re: xid wraparound