Re: [v9.3] Extra Daemons (Re: elegant and effective way for running jobs inside a database)

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Kohei KaiGai <kaigai(at)kaigai(dot)gr(dot)jp>
Cc: Simon Riggs <simon(at)2ndquadrant(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, "David E(dot) Wheeler" <david(at)justatheory(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [v9.3] Extra Daemons (Re: elegant and effective way for running jobs inside a database)
Date: 2012-11-21 21:29:20
Message-ID: 20121121212919.GE4210@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Alvaro Herrera escribió:
> FWIW I have pushed this to github; see
> https://github.com/alvherre/postgres/compare/bgworker
>
> It's also attached.
>
> The UnBlockSig stuff is the main stumbling block as I see it because it
> precludes compilation on Windows. Maybe we should fix that by providing
> another function that the module is to call after initialization is done
> and before it gets ready to work ... but having a function that only
> calls PG_SETMASK() feels somewhat useless to me; and I don't see what
> else we could do in there.

I cleaned up some more stuff and here's another version. In particular
I added wrapper functions to block and unblock signals, so that this
doesn't need exported UnBlockSig.

I also changed ServerLoop so that it sleeps until a crashed bgworker
needs to be restarted -- if a worker terminates, and it has requested
(say) 2s restart time, don't have it wait until the full 60s postmaster
sleep time has elapsed.

The sample code has been propped up somewhat, too.

--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

Attachment Content-Type Size
bgworker-7.patch text/x-diff 66.5 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Smith 2012-11-21 21:30:05 Re: WIP patch for hint bit i/o mitigation
Previous Message Magnus Hagander 2012-11-21 21:15:35 Re: PQconninfo function for libpq