Re: elog during holding a spinlock is safe?

Lists: pgsql-hackers
From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: elog during holding a spinlock is safe?
Date: 2010-09-15 02:27:34
Message-ID: AANLkTim7ewtxN6orG+8z5mHByyeKx7zvBvpJpUvv1zw+@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

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


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Heikki Linnakangas <heikki(at)enterprisedb(dot)com>
Subject: Re: elog during holding a spinlock is safe?
Date: 2010-09-15 02:47:10
Message-ID: 24088.1284518830@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Fujii Masao <masao(dot)fujii(at)gmail(dot)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


From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: elog during holding a spinlock is safe?
Date: 2010-09-15 06:51:16
Message-ID: 4C906CE4.9010609@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 15/09/10 05:47, Tom Lane wrote:
> Fujii Masao<masao(dot)fujii(at)gmail(dot)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