Re: SIREAD lock versus ACCESS EXCLUSIVE lock

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

Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> If you don't believe that a catcache lookup will ever fail, I will
> contract to break the patch.

As you probably know by now by reaching the end of the thread, this
code is going away based on Heikki's arguments; but for my
understanding, so that I don't make a bad assumption in this area
again, what could cause the following function to throw an exception
if the current process is holding an exclusive lock on the relation
passed in to it? (I could be a heap or an index relation.) It
seemed safe to me, and I can't spot the risk on a scan of the called
functions. What am I missing?

static Oid
IfIndexGetRelation(Oid indexId)
{
HeapTuple tuple;
Form_pg_index index;
Oid result;

tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(indexId));
if (!HeapTupleIsValid(tuple))
return InvalidOid;

index = (Form_pg_index) GETSTRUCT(tuple);
Assert(index->indexrelid == indexId);

result = index->indrelid;
ReleaseSysCache(tuple);
return result;
}

Thanks for any clues,

-Kevin

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Merlin Moncure 2011-06-07 14:57:19 Re: Range Types and extensions
Previous Message Tom Lane 2011-06-07 14:37:30 Re: BUG #6041: Unlogged table was created bad in slave node