Re: WaitLatchOrSocket seems to not count to 4 right... - Mailing list pgsql-hackers

From Thomas Munro
Subject Re: WaitLatchOrSocket seems to not count to 4 right...
Date
Msg-id CA+hUKG+iaLp6ETo+u0632yVUGO6eSMx4hKBbcc7zy88thBQy=g@mail.gmail.com
Whole thread Raw
In response to Re: WaitLatchOrSocket seems to not count to 4 right...  (Fujii Masao <masao.fujii@oss.nttdata.com>)
Responses Re: WaitLatchOrSocket seems to not count to 4 right...  (Fujii Masao <masao.fujii@oss.nttdata.com>)
Re: WaitLatchOrSocket seems to not count to 4 right...  (Thomas Munro <thomas.munro@gmail.com>)
List pgsql-hackers
On Tue, Feb 8, 2022 at 1:48 PM Fujii Masao <masao.fujii@oss.nttdata.com> wrote:
> On 2022/02/08 7:00, Greg Stark wrote:
> > Unless I'm misreading this code I think the nevents in
> > WaitLatchOrSocket should really be 4 not 3. At least there are 4 calls
> > to AddWaitEventToSet in it and I think it's possible to trigger all 4.
>
> Good catch! I think you're right.
>
> As the quick test, I confirmed that the assertion failure happened when I passed four possible events to
WaitLatchOrSocket()in postgres_fdw.
 
>
> TRAP: FailedAssertion("set->nevents < set->nevents_space", File: "latch.c", Line: 868, PID: 54424)

Yeah, the assertion shows there's no problem, but we should change it
to 4 (and one day we should make it dynamic and change udata to hold
an index instead of a pointer...) or, since it's a bit silly to add
both of those events, maybe we should do:

-       if ((wakeEvents & WL_POSTMASTER_DEATH) && IsUnderPostmaster)
-               AddWaitEventToSet(set, WL_POSTMASTER_DEATH, PGINVALID_SOCKET,
-                                                 NULL, NULL);
-
        if ((wakeEvents & WL_EXIT_ON_PM_DEATH) && IsUnderPostmaster)
                AddWaitEventToSet(set, WL_EXIT_ON_PM_DEATH, PGINVALID_SOCKET,
                                                  NULL, NULL);
+       else if ((wakeEvents & WL_POSTMASTER_DEATH) && IsUnderPostmaster)
+               AddWaitEventToSet(set, WL_POSTMASTER_DEATH, PGINVALID_SOCKET,
+



pgsql-hackers by date:

Previous
From: Fujii Masao
Date:
Subject: Re: WaitLatchOrSocket seems to not count to 4 right...
Next
From: Tom Lane
Date:
Subject: Re: [PATCH] Add UPDATE WHERE OFFSET IN clause