From: | Craig Ringer <craig(at)2ndquadrant(dot)com> |
---|---|
To: | Abbas Butt <abbas(dot)butt(at)enterprisedb(dot)com> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Marc Linster <marc(dot)linster(at)enterprisedb(dot)com>, "A(dot) Hayee" <hayee(dot)bhatti(at)enterprisedb(dot)com>, Hope Jiang <hope(dot)jiang(at)enterprisedb(dot)com>, Priti Sarode <priti(dot)sarode(at)enterprisedb(dot)com>, Ahsan Hadi <ahsan(dot)hadi(at)enterprisedb(dot)com> |
Subject: | Re: Latches API on windows |
Date: | 2017-10-09 13:47:39 |
Message-ID: | CAMsr+YEmFLd-KKAJmWW7CpWPSud8Uv51j5kkoE_d_Wsbj5EBQQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 9 October 2017 at 21:26, Abbas Butt <abbas(dot)butt(at)enterprisedb(dot)com> wrote:
> Hi,
> I am working on a contrib module that uses RegisterDynamicBackgroundWorker
> API
> to create a couple of worker processes. For synchronization between the
> background worker processes I am using InitSharedLatch, SetLatch, WaitLatch
> APIs.
> One of the processes is supposed to wait for the latch, the other is
> supposed to set it.
> The system works perfectly fine as long as its run on Linux, however when
> tried
> on Windows, it fails giving the error:
> ResetEvent failed: error code 6
> Error code 6 means invalid handle. Debugging reveals that the handle
> contains
> a valid value, however it seems that the handle is not accessible (was not
> created)
> in the process that is calling ResetEvent.
>
> Debugging the issue lead me to the following comment on top of
> InitSharedLatch:
>
> * InitSharedLatch needs to be called in postmaster before forking child
> * processes, usually right after allocating the shared memory block
> * containing the latch with ShmemInitStruct. (The Unix implementation
> * doesn't actually require that, but the Windows one does.)
>
> In my case this is not true, I am calling InitSharedLatch in _PG_init
> which gets called at CREATE EXTENSION time.
> My question : Is there a way to get the latches API work on windows
> the way it is working on Linux?
I suspect you'd need to do it by having your extension load via
shared_preload_libraries, registering its latch in shmem_startup_hook
.
But ... that's an off-the-cuff guess.
--
Craig Ringer http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2017-10-09 13:56:10 | Re: Latches API on windows |
Previous Message | Julien Rouhaud | 2017-10-09 13:35:28 | oversight in EphemeralNamedRelation support |