Re: [COMMITTERS] pgsql: Improve concurrency of foreign key locking

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [COMMITTERS] pgsql: Improve concurrency of foreign key locking
Date: 2013-01-24 16:57:08
Message-ID: 20130124165708.GD4528@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

Alvaro Herrera wrote:
> Improve concurrency of foreign key locking

I noticed a bug in visibility routines when pg_upgrade is involved:
tuples marked FOR UPDATE in the old cluster (i.e. HEAP_XMAX_INVALID not
set, HEAP_XMAX_EXCL_LOCK set, HEAP_XMAX_IS_MULTI not set) are invisible
(dead) on the new cluster. I had defined the HEAP_XMAX_IS_LOCKED_ONLY
thusly:

#define HEAP_XMAX_IS_LOCKED_ONLY(infomask) \
((infomask) & HEAP_XMAX_LOCK_ONLY)

but this doesn't work for the reason stated above. The fix is to
redefine the macro like this:

/*
* A tuple is only locked (i.e. not updated by its Xmax) if the
* HEAP_XMAX_LOCK_ONLY bit is set; or, for pg_upgrade's sake, if the Xmax is
* not a multi and the EXCL_LOCK bit is set.
*
* See also HeapTupleHeaderIsOnlyLocked, which also checks for a possible
* aborted updater transaction.
*
* Beware of multiple evaluations of the argument.
*/
#define HEAP_XMAX_IS_LOCKED_ONLY(infomask) \
(((infomask) & HEAP_XMAX_LOCK_ONLY) || \
(((infomask) & (HEAP_XMAX_IS_MULTI | HEAP_LOCK_MASK)) == HEAP_XMAX_EXCL_LOCK))

--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Browse pgsql-committers by date

  From Date Subject
Next Message Noah Misch 2013-01-24 18:07:54 Re: Materialized views WIP patch
Previous Message Alvaro Herrera 2013-01-24 14:55:46 pgsql: Don't require oldestMultixact if server doesn't have it

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2013-01-24 17:02:59 Re: Re: Proposal for Allow postgresql.conf values to be changed via SQL [review]
Previous Message Fujii Masao 2013-01-24 16:55:15 Re: Back-branch update releases coming in a couple weeks