Re: Fix spinlock usage in UnpinBuffer()

From: Qingqing Zhou <zhouqq(at)cs(dot)toronto(dot)edu>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: Fix spinlock usage in UnpinBuffer()
Date: 2005-12-29 00:04:28
Message-ID: Pine.LNX.4.58.0512281754100.13811@eon.cs
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2005-12-29 02:38:33 Re: Fix spinlock usage in UnpinBuffer()
Previous Message Tom Lane 2005-12-28 19:56:29 Re: Fix spinlock usage in UnpinBuffer()