Skip site navigation (1) Skip section navigation (2)

Re: lock listing

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: nconway(at)klamath(dot)dyndns(dot)org (Neil Conway)
Cc: PostgreSQL Patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: lock listing
Date: 2002-07-19 21:15:43
Message-ID: 15383.1027113343@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-patches
nconway(at)klamath(dot)dyndns(dot)org (Neil Conway) writes:
> On Fri, Jul 19, 2002 at 01:21:10PM -0400, Tom Lane wrote:
>> I'm very unthrilled with this approach to faking up a composite type
>> for pg_show_locks to return.

> As am I, and I agree that the proper long-term answer is some new
> infrastructure for adding builtin SRFs. However, I don't think that's
> a really good reason for rejecting the patch --

I'm not wanting to reject the patch; I'm wanting to restructure it as
additions to lmgr.c plus a contrib module that includes the API function
and perhaps some sample views.  The contrib module's install script
could avoid these pesky problems because it can just CREATE a dummy
table or view and then CREATE the function.  Once we have a better
answer about declaring built-in SRFs, we can migrate the code into the
core.

>> It seems to me that you could do one palloc, or at most three, while
>> holding the LockMgrLock --- doing three per holderTable entry will take
>> significantly longer.

> Can you elaborate a bit on what changes you'd like to see? Can this
> be done with the data structures I'm using now, or do I need to roll
> my own?

You could get down to 3 pallocs (which is enough of a savings for me)
by creating the workspace as an array of nelements PROCLOCK structs,
an array of nelements PGPROC structs, and an array of nlements LOCK
structs.  The intermediate pointer arrays don't seem to buy anything
much except palloc overhead.

>> This seems quite wrong; the active context when the function is called
>> will be a short-term context, which *will* get reset before the next
>> call.  Have you tested this with --enable-cassert (which turns on
>> CLOBBER_FREED_MEMORY)?  I think you need to switch into a longer-lived
>> context before calling GetLockStatusData.

> Hmmm -- I tested it with '--enable-cassert' and didn't observe any
> problems. I've revised to patch to allocate that long-term memory in
> FuncCallContext.fctx, which I think should be sufficiently long-lived.

Yeah, that's where it should go.  I'm puzzled why you didn't observe
a failure ...

			regards, tom lane

In response to

Responses

pgsql-patches by date

Next:From: Bruce MomjianDate: 2002-07-20 00:07:52
Subject: Re: lock listing
Previous:From: Neil ConwayDate: 2002-07-19 21:04:09
Subject: Re: lock listing

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group