Re: Fix spinlock usage in UnpinBuffer() - Mailing list pgsql-patches

From Qingqing Zhou
Subject Re: Fix spinlock usage in UnpinBuffer()
Date
Msg-id Pine.LNX.4.58.0512281754100.13811@eon.cs
Whole thread Raw
In response to Re: Fix spinlock usage in UnpinBuffer()  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-patches

On Wed, 28 Dec 2005, Tom Lane wrote:
>
> Because the code uses _NoHoldoff, there won't be any check of
> InterruptPending in that segment of code.

I guess the danger I claimed may not really happen because of the
"ImmediateInterruptOK" variable. Since it is almost always false (except
reading inputs and some very limited local usage), so even we don't
HOLD_INTERRUPTS() in UnpinBuffer(), we are still protected by this
variable in die() when a SIGTERM sneaks in.  -- But this is dangerous
AFAICS, since we must gaurantee that nowhere during holding BufHdrLock
will invoke CHECK_FOR_INTERRUPTS(), which is *not* protected by
"ImmediateInterruptOK".

In other words, if we agree that the above behavior is safe, then we can
use _NoHoldoff in almost the whole buffer manager code on condition that
we are sure that no CHECK_FOR_INTERRUPTS() invoked while holding spinlock.
So for example, in UnlockBuffers(), remove the HOLD_INTERRUPTS() pair; in
write_buffer(), change LockBufHdr() to LockBufferHdr_NoHoldoff().

Regards,
Qingqing

pgsql-patches by date:

Previous
From: Tom Lane
Date:
Subject: Re: Fix spinlock usage in UnpinBuffer()
Next
From: Tom Lane
Date:
Subject: Re: Fix spinlock usage in UnpinBuffer()