Re: On-the-fly index tuple deletion vs. hot_standby

From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: Noah Misch <noah(at)leadboat(dot)com>
Cc: Simon Riggs <simon(at)2ndQuadrant(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: On-the-fly index tuple deletion vs. hot_standby
Date: 2011-03-11 07:45:40
Message-ID: 4D79D324.2010001@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 10.12.2010 19:55, Noah Misch wrote:
> On Thu, Dec 09, 2010 at 09:48:25AM +0000, Simon Riggs wrote:
>> On Fri, 2010-12-03 at 21:43 +0200, Heikki Linnakangas wrote:
>>> Seems reasonable. HeapTupleHeaderAdvanceLatestRemovedXid() will need
>>> similar treatment. Actually, btree_xlog_delete_get_latestRemovedXid()
>>> could just call HeapTupleHeaderAdvanceLatestRemoveXid().
>>
>> Yes, it applies to other cases also. Thanks for the suggestion.
>>
>> Fix committed. Please double-check my work, committed early since I'm
>> about to jump on a plane.
>
> Thanks for making that change. For my understanding, why does the xmin == xmax
> special case in HeapTupleHeaderAdvanceLatestRemoveXid not require !HEAP_UPDATED,
> as the corresponding case in HeapTupleSatisfiesVacuum requires? I can neither
> think of a recipe for triggering a problem as the code stands, nor come up with
> a sound explanation for why no such recipe can exist.

The difference is in the purpose of those two functions.
HeapTupleSatisfiesVacuum decides if a tuple can be safely vacuumed away.
For that purpose, you can't remove a tuple from the middle of an update
chain, even if that tuple was never visible to any other transaction,
because someone might still want to follow the update chain to find the
latest version of the row. HeapTupleHeaderAdvanceLatestRemoveXid is used
to decide if removing a tuple would conflict with in-progress hot
standby queries. For that purpose, you don't need to care about breaking
update chains, as Hot Standby is only used for read-only queries and
read-only queries never follow update chains.

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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2011-03-11 07:46:10 Re: Hot Standby btree delete records and vacuum_defer_cleanup_age
Previous Message Pavel Stehule 2011-03-11 06:09:37 Re: patch: fix performance problems with repated decomprimation of varlena values in plpgsql