Is there any way to request unique lwlock inside a background worker in PG9.4?

2018-10-17 Thread Hubert Zhang
Hi all, I want to init SHM in a background worker, which is supported in PG9.4. Also I need to use lwlock to protect the share memory inside the worker code. RequestNamedLWLockTranche is the way to handle it, but it's not supported in PG 9.4, is there any way I could request an unique lock inside

Re: Is there any way to request unique lwlock inside a background worker in PG9.4?

2018-10-17 Thread Amit Kapila
On Wed, Oct 17, 2018 at 3:49 PM Hubert Zhang wrote: > > Hi all, > > I want to init SHM in a background worker, which is supported in PG9.4. Also > I need to use lwlock to protect the share memory inside the worker code. > > RequestNamedLWLockTranche is the way to handle it, but it's not supported

Re: Is there any way to request unique lwlock inside a background worker in PG9.4?

2018-10-17 Thread Hubert Zhang
Hi Amit The section "Share Memory and LWLocks" describe the AddinShmemInitLock which is used to protect the ShmemInitStruct() when backend workers initialize their shm. My requirement is to how to protect the shm access within the bgworkers(not at init stage). This lock should be bgworkers specif

Re: Is there any way to request unique lwlock inside a background worker in PG9.4?

2018-10-17 Thread Andres Freund
Hi, On 2018-10-17 23:11:26 +0800, Hubert Zhang wrote: > The section "Share Memory and LWLocks" describe the AddinShmemInitLock which > is used to protect the ShmemInitStruct() when backend workers initialize > their shm. My requirement is to how to protect the shm access within the > bgworkers(no

Re: Is there any way to request unique lwlock inside a background worker in PG9.4?

2018-10-17 Thread Hubert Zhang
Thanks a lot. On Wed, Oct 17, 2018 at 11:21 PM Andres Freund wrote: > Hi, > > On 2018-10-17 23:11:26 +0800, Hubert Zhang wrote: > > The section "Share Memory and LWLocks" describe the AddinShmemInitLock > which > > is used to protect the ShmemInitStruct() when backend workers initialize > > thei