On Tue, Feb 8, 2022 at 1:48 PM Fujii Masao <masao.fu...@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, +