Re: SIREAD lock versus ACCESS EXCLUSIVE lock

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: <heikki(dot)linnakangas(at)enterprisedb(dot)com>, "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
Cc: <simon(at)2ndquadrant(dot)com>,<drkp(at)csail(dot)mit(dot)edu>, <pgsql-hackers(at)postgresql(dot)org>, <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: SIREAD lock versus ACCESS EXCLUSIVE lock
Date: 2011-06-07 12:59:34
Message-ID: 4DEDDA66020000250003E24F@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"Kevin Grittner" wrote:
> Heikki Linnakangas wrote:
>
>> I think the logic is actually wrong at the moment: When you
>> reindex a single index, DropAllPredicateLocksFromTableImpl() will
>> transfer all locks belonging to any index on the same table, and
>> any finer-granularity locks on the heap. It would be enough to
>> transfer only locks on the index being reindexed, so you risk
>> getting some unnecessary false positives.
>
> It seemed like a good idea at the time -- a relation lock on the
> heap makes any other locks on the heap or any of its indexes
> redundant. So it was an attempt at "cleaning house". Since we
> don't do anything for an index request unless there is a lock on
> that index, it couldn't cause false positives. But this probably
> fits into the category of premature optimizations, since the locks
> can't cause any difference in when you get a serialization failure
> -- it's only a matter of "taking up space". I could revert that.

On reflection, Heikki was dead-on right here; I had some fuzzy
thinking going. Just because one transaction has a lock in the index
doesn't mean that all transactions need lock promotion. That still
leaves an opportunity for cleanup, but it's much narrower -- only
locks from transactions which held locks on the reorganized index can
be replaced by the heap relation lock. That one is narrow enough to
be very unlikely to be worthwhile.

As usual, Heikki was right on target. :-)

-Kevin

Browse pgsql-hackers by date

  From Date Subject
Next Message Stephen Frost 2011-06-07 13:24:11 Re: reducing the overhead of frequent table locks - now, with WIP patch
Previous Message Simon Riggs 2011-06-07 12:54:11 Re: WALInsertLock tuning