Re: [COMMITTERS] pgsql: Fix traversal of half-frozen update chains

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [COMMITTERS] pgsql: Fix traversal of half-frozen update chains
Date: 2017-10-19 20:44:01
Message-ID: CAH2-Wz=+pi+0kLRrqTiGoYMZbqD-8Nvd0mj0kLu8XNJi5Hpz_w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

On Thu, Oct 19, 2017 at 9:03 AM, Peter Geoghegan <pg(at)bowt(dot)ie> wrote:
>> /me studies the problem for a while.
>>
>> What's bothering me about this is: how is cutoff_xid managing to be a
>> new enough transaction ID for this to happen in the first place? The
>> cutoff XID should certainly be older than anything any current
>> snapshot can see, because it's computed using GetOldestXmin() -- which
>> means that XIDs older than the cutoff can't still be running (except
>> maybe if old_snapshot_threshold is set to a non-default value).

> Now that the problem is fixed by a5736bf7, this test case will prune
> and get an LP_REDIRECT ItemId (not an LP_DEAD one), as we're no longer
> confused about the continuity of HOT chains within heap_prune_chain().

In case I was unclear: the key point here is that it wasn't wrong to
prune the tuples because they might still be visible to somebody's
snapshot. It was wrong to do so in a specific way that could still
happen prior to a5736bf7, leaving only a stub LP_DEAD line pointer,
because index scans needed to do HOT chain traversal in order to get
to the visible tuple that wasn't pruned (the one that was still
frozen). You might say that the HOT chain "appeared to split in two"
from heap_prune_chain()'s perspective, a problem that has nothing to
do with an XID cutoff.

That's why after 20b65522 there was no problem with sequential scans.
There were remaining problems with index scans, though, purely because
of this HOT pruning business -- that was fixed in a5736bf7. (And, as
I've said, problems with "traversal of half-frozen update chains" are
presumed to have existed for routines like EvalPlanQual() -- even more
subtle problems.)

One thing I'm not clear on is if we could or should have limited this
new HeapTupleUpdateXmaxMatchesXmin() stuff to HOT chains, and so not
altered behavior for cross-page cases (for routines like
EvalPlanQualFetch() -- not routines like heap_prune_chain(), that only
ever deal with a single page at a time).

--
Peter Geoghegan

In response to

Browse pgsql-committers by date

  From Date Subject
Next Message Robert Haas 2017-10-20 13:44:12 pgsql: pg_stat_statements: Add a comment about the dangers of padding b
Previous Message Peter Geoghegan 2017-10-19 16:03:47 Re: [COMMITTERS] pgsql: Fix traversal of half-frozen update chains

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2017-10-19 20:46:53 Re: Domains and arrays and composites, oh my
Previous Message Tomasz Ostrowski 2017-10-19 20:42:04 Queuing all tables for analyze after recovery