Re: Unportable implementation of background worker start

From: Andres Freund <andres(at)anarazel(dot)de>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Unportable implementation of background worker start
Date: 2017-04-21 18:40:06
Message-ID: 20170421184006.n4fxucox2gpinjly@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom,

On 2017-04-21 13:49:27 -0400, Tom Lane wrote:
> >> * If we are in PM_WAIT_DEAD_END state, then we don't want to accept
> >> - * any new connections, so we don't call select(), and just sleep.
> >> + * any new connections, so we don't call WaitEventSetWait(), and just
> >> + * sleep. XXX not ideal
> >> */
>
> > Couldn't we just deactive the sockets in the set instead?
>
> Yeah, I think it'd be better to do something like that. The pg_usleep
> call has the same issue of possibly not responding to interrupts. The
> risks are a lot less, since it's a much shorter wait, but I would rather
> eliminate the separate code path in favor of doing it honestly. Didn't
> seem like something to fuss over in the first draft though.

Ok, cool.

> >> + ServerWaitSet = CreateWaitEventSet(PostmasterContext, MAXLISTEN + 1);
>
> > Why are we using MAXLISTEN, rather than the actual number of things to
> > listen to?
>
> It'd take more code (ie, an additional scan of the array) to predetermine
> that. I figured the space-per-item in the WaitEventSet wasn't enough to
> worry about ... do you think differently?

I'm not sure. We do create an epoll handler with enough space, and that
has some overhead. Don't know whether that's worthwhile to care about.

> > I kind of would like, in master, take a chance of replace all the work
> > done in signal handlers, by just a SetLatch(), and do it outside of
> > signal handlers instead. Forking from signal handlers is just plain
> > weird.
>
> Yeah, maybe it's time. But in v11, and not for back-patch.

Agreed.

- Andres

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message buschmann 2017-04-21 18:40:12 BUG #14629: ALTER TABLE VALIDATE CONSTRAINTS does not obey NO INHERIT clause
Previous Message Andres Freund 2017-04-21 18:21:24 Re: Unportable implementation of background worker start