Re: [BUG FIX] Removing NamedLWLockTrancheArray

From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [BUG FIX] Removing NamedLWLockTrancheArray
Date: 2017-03-04 04:37:50
Message-ID: CAA4eK1J0DcZun00PwSiftvUjpGfD2zq8CYXv9RYtiJPGbraPTw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Mar 3, 2017 at 3:49 PM, Kyotaro HORIGUCHI
<horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp> wrote:
>> You can read about usage of LWLocks in extensions from below location:
>> https://www.postgresql.org/docs/devel/static/xfunc-c.html#idp86986416
>
> Thank you for the pointer. I understand that the document describes the only
> correct way to use LWLock in extensions and using LWLockRegisterTranche is
> a non-standard or prohibit way to do that.
>
> By the way, in the case of orafce, it uses LWLockRegisterTranche directly
> but only when !found. So if any backend other than the creator of the shmem
> want to access tranche, the puch tranche is not found on the process and
> crashes. I think this is it.
>

Yeah and I think that is expected if you use LWLockRegisterTranche.
You might want to read comments in lwlock.h to know the reason behind
the same.

> If no other modules is installed, registeriing a tranche even if found will
> supress the crash but it is not a solution at all.
>
> At least for 9.6 or 10, orafce should do that following the documentation.
>

Agreed.

> But it still can crash from the problem by the separate
> NamedLWLockTrancheArray. (ID range check in LWLockInitialize would be
> useless if it is not used by extensions)
>

What exact problem are you referring here?

--
With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2017-03-04 04:46:40 Re: DROP SUBSCRIPTION and ROLLBACK
Previous Message Tom Lane 2017-03-04 04:11:33 Re: [COMMITTERS] pgsql: Use asynchronous connect API in libpqwalreceiver