Re: Lock conflict behavior?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Tatsuo Ishii <ishii(at)postgresql(dot)org>
Cc: pgsql(at)j-davis(dot)com, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Lock conflict behavior?
Date: 2008-12-23 13:48:45
Message-ID: 24978.1230040125@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tatsuo Ishii <ishii(at)postgresql(dot)org> writes:
>> LOCK TABLE checks the permissions before attempting to acquire the lock,
>> is there a reason that ALTER TABLE doesn't?

> Right. I think we should check the permissions first too.

I've always thought that it was extremely shaky for LOCK to try to work
that way. With no lock, you have no confidence that the table isn't
changing or disappearing under you. In the worst case, the permissions
check might fail outright (likely with a "cache lookup failed" message
about a catalog row that disappeared as we attempted to fetch it); or it
might give an answer that's obsolete by the time we do acquire the lock.

The present coding of LOCK dates from before we had fixed things to
guarantee that relation_open() acquires table lock before attempting to
load the relcache entry. Back then, there were enough race conditions
involved in first access to a relation that one more didn't seem to
matter. But now, I'd sure insist on someone finding a more bulletproof
answer before I'd hold still for extending that bogus coding pattern
all over the system.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2008-12-23 14:12:45 Re: encoding cleanups in cvs repo
Previous Message Simon Riggs 2008-12-23 13:41:41 Re: Sync Rep: First Thoughts on Code