elog during holding a spinlock is safe?

Started by Fujii Masaoover 15 years ago3 messages
#1Fujii Masao
masao.fujii@gmail.com

Hi,

In HEAD, OwnLatch can elog during holding the spinlock WalSnd->mutex.
This seems to be unsafe because that elog would cause the walsender
to exit without releasing the spinlock. Because of the spinlock being
held, subsequent walsender would get stuck. I wonder if OwnLatch really
needs to be protected by the spinlock.

Regards,

--
Fujii Masao
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Fujii Masao (#1)
Re: elog during holding a spinlock is safe?

Fujii Masao <masao.fujii@gmail.com> writes:

In HEAD, OwnLatch can elog during holding the spinlock WalSnd->mutex.
This seems to be unsafe

Even if it were safe, holding a spinlock through non-straight-line code
is a complete violation of the spinlock coding rules re the length of
time you're supposed to hold the lock. Heikki?

regards, tom lane

#3Heikki Linnakangas
heikki.linnakangas@enterprisedb.com
In reply to: Tom Lane (#2)
Re: elog during holding a spinlock is safe?

On 15/09/10 05:47, Tom Lane wrote:

Fujii Masao<masao.fujii@gmail.com> writes:

In HEAD, OwnLatch can elog during holding the spinlock WalSnd->mutex.
This seems to be unsafe

Even if it were safe, holding a spinlock through non-straight-line code
is a complete violation of the spinlock coding rules re the length of
time you're supposed to hold the lock. Heikki?

Yep, that's an oversight. I'll move the OwnLatch call after the spinlock
is released.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com