From: | Simon Riggs <simon(at)2ndQuadrant(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Reducing some DDL Locks to ShareLock |
Date: | 2008-11-18 19:50:54 |
Message-ID: | 1227037854.5748.44.camel@ebony.2ndQuadrant |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Wed, 2008-11-12 at 16:25 -0500, Tom Lane wrote:
> The alternative I was thinking about involved taking an exclusive buffer
> lock on the page containing the tuple to be updated in-place. The point
> being that you have to examine the old tuple contents and decide whether
> to update after you have lock, not before. I think this would amount to
> refactoring heap_inplace_update into two operations: fetch/lock and
> update/unlock. (I guess there should be a third function to release
> without updating, too --- that would really just be an unlock-buffer
> operation, but it'd be better if callers didn't explicitly know that.)
> The callers would probably still use the syscache to obtain the tuple
> address, but they wouldn't rely on it to supply the tuple image.
Here's what I'm working on:
HeapTuple
heap_inplace_xxx(Relation relation, HeapTuple tuple, Buffer *buffer)
xxx = (fetch, update, release)
usage:
tuple = heap_inplace_fetch(rel, tuple, &buffer);
....
if (dirty)
heap_inplace_fe(rel, tuple, &buffer);
else
heap_inplace_fetch(rel, tuple, &buffer);
heap_inplace_fetch takes as input "tuple" which is a palloc'd tuple,
extracts from it the tid of the tuple, reads the buffer, locks it, then
releases the original tuple. It then returns a copy of the on-block
tuple. So all other code the same as before when we were working on a
copy produced from the syscache.
Is that roughly what you intended?
--
Simon Riggs www.2ndQuadrant.com
PostgreSQL Training, Services and Support
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2008-11-18 20:04:36 | Re: Reducing some DDL Locks to ShareLock |
Previous Message | Andrew Chernow | 2008-11-18 19:07:33 | solaris libpq threaded build fails |