pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Mark Rostron <mrostron@ql2.com>
Cc: pgsql-admin@postgresql.org <pgsql-admin@postgresql.org>
Subject: Re: xid wraparound
Date: Sun, 26 Sep 2010 20:42:59 -0400
Message-ID: <20488.1285548179@sss.pgh.pa.us> (raw)
In-Reply-To: <FD020D3E50E7FA479567872E5F5F31E3045A05CBA1@ex01.corp.ql2.com>
References: <FD020D3E50E7FA479567872E5F5F31E3045A05CB90@ex01.corp.ql2.com>
	<17534.1285462422@sss.pgh.pa.us>
	<FD020D3E50E7FA479567872E5F5F31E3045A05CBA1@ex01.corp.ql2.com>

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



view thread (6+ messages)  latest in thread

Message-ID: <20488.1285548179@sss.pgh.pa.us>
Permalink:  ../20488.1285548179@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/20488.1285548179@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: tgl@sss.pgh.pa.us, mrostron@ql2.com
  Subject: Re: xid wraparound
  In-Reply-To: <20488.1285548179@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox