Re: advancing snapshot's xmin

From: Heikki Linnakangas <heikki(at)enterprisedb(dot)com>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Gregory Stark <stark(at)enterprisedb(dot)com>, Neil Conway <neilc(at)samurai(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: advancing snapshot's xmin
Date: 2008-03-28 16:14:58
Message-ID: 47ED1982.1030807@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Alvaro Herrera wrote:
> Heikki Linnakangas wrote:
>> Alvaro Herrera wrote:
>>> Tom Lane wrote:
>>>> Alvaro Herrera <alvherre(at)commandprompt(dot)com> writes:
>>>>> As far as I can see, for the purposes of VACUUM we can remove any tuple
>>>>> that was deleted after the old transaction's Xid but before that
>>>>> transaction's Xmin (i.e. all of its live snapshots). This means we get
>>>>> to ignore Xid in GetOldestXmin and in the TransactionXmin calculations
>>>>> in GetSnapshotData. It would not surprise me, however, to find out that
>>>>> I am overlooking something and this is incorrect.
>>>> This seems entirely off-base to me. In particular, if a transaction
>>>> has an XID then its XMIN will never be greater than that, so I don't
>>>> even see how you figure the case will arise.
>>> My point exactly -- can we let the Xmin go past its Xid? You imply we
>>> can't, but why?
>> Everything < xmin is considered to be not running anymore. Other
>> transactions would consider the still-alive transaction as aborted, and
>> start setting hint bits etc.
>
> Okay. So let's say we invent another TransactionId counter -- we keep
> Xmin for the current purposes, and the other counter keeps track of
> snapshots ignoring Xid. This new counter could be used by VACUUM to
> trim dead tuples.

Hmm. So if we call that counter VacuumXmin for now, you could remove
deleted rows with xmax < VacuumXmin, as long as that xmax is not in the
set of running transactions? I guess that would work.

In general: VACUUM can remove any tuple that's not visible to any
snapshot in the system. We don't want to keep all snapshots in shared
memory, so we use some conservative approximation of that.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2008-03-28 16:25:56 Re: Prereading using posix_fadvise (was Re: Commitfest patches)
Previous Message Brendan Jurd 2008-03-28 16:12:51 Re: [PATCHES] Text <-> C string