Re: [HACKERS] Anyone understand shared buffer refcount mechanism?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Vadim Mikheev <vadim(at)krs(dot)ru>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] Anyone understand shared buffer refcount mechanism?
Date: 1999-09-20 14:07:52
Message-ID: 13641.937836472@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Vadim Mikheev <vadim(at)krs(dot)ru> writes:
> Tom Lane wrote:
>> In trying to understand what the code is doing, I am confused by the
>> buffer refcount save/restore mechanism. Why does the executor want
>> to save/restore buffer refcounts? I can sort of see that that might

> This bothered me for long time too.
> The only explanation I see in execMain.c:

> * this makes sure that when ExecutorRun's are called recursively as for
> * postquel functions, the buffers pinned by one ExecutorRun will not
> * be unpinned by another ExecutorRun.

The case that is currently failing for me is postquel function calls
(the "misc" regress test contains some, and it's spewing Buffer Leak
notices like crazy, now that I fixed BufferLeakCheck to notice nonzero
LastRefCount as well as nonzero PrivateRefCount). So there's something
rotten here. I will keep looking at it.

> So, try to remove this save/restore mechanism and let's see...

It does seem that BufferRefCountRestore is actually unpinning some
things (things got much better after I fixed it to really do the
unpin when restoring a nonzero refcount to zero). So I don't
think I want to try to take out the save/restore entirely. What
it looks like right now is that a few specific paths through the
executor restore the wrong counts...

regards, tom lane

Browse pgsql-hackers by date

  From Date Subject
Next Message Vadim Mikheev 1999-09-20 14:09:20 Re: [HACKERS] why do shmem attach?
Previous Message Tom Lane 1999-09-20 14:00:39 Re: [HACKERS] Notice: heap_open/close changes committed