From:
Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To:
Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc:
Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject:
Re: Interruptible sleeps (was Re: CommitFest 2009-07: Yay,
Kevin! Thanks, reviewers!)
Date:
2010-09-01 07:11:39
Message-ID:
4C7DFCAB.3090809@enterprisedb.com (view raw or flat )
Thread:
2010-08-18 20:40:20 from Robert Haas <robertmhaas(at)gmail(dot)com>
2010-08-18 21:21:05 from "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
2010-08-18 23:46:08 from Greg Smith <greg(at)2ndquadrant(dot)com>
2010-08-19 01:46:45 from Robert Haas <robertmhaas(at)gmail(dot)com>
2010-08-19 06:02:34 from Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
2010-08-19 13:38:02 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2010-08-19 16:23:23 from Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
2010-08-19 16:57:26 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2010-08-19 17:04:09 from Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
2010-08-19 17:18:57 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2010-08-19 17:36:09 from Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
2010-08-19 17:59:51 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2010-08-20 13:15:48 from Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
2010-08-20 13:24:31 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2010-08-20 14:15:47 from Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
2010-08-20 14:28:04 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2010-08-23 21:30:04 from Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
2010-08-23 23:44:02 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2010-08-24 01:08:21 from Alvaro Herrera <alvherre(at)commandprompt(dot)com>
2010-08-24 08:42:49 from Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
2010-08-26 10:40:10 from Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
2010-08-27 07:39:14 from Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
2010-08-27 08:15:28 from Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
2010-08-31 07:06:42 from Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
2010-08-31 10:40:10 from Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
2010-08-31 12:47:51 from Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
2010-09-01 07:11:39 from Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
2010-09-02 03:46:16 from Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
2010-09-02 18:30:59 from Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
2010-09-02 20:13:38 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2010-09-03 02:02:25 from Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
2010-09-03 02:08:08 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2010-09-03 04:19:17 from Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
2010-09-03 14:07:25 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2010-09-03 15:43:50 from Robert Haas <robertmhaas(at)gmail(dot)com>
2010-09-03 16:10:42 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2010-09-03 16:38:52 from Robert Haas <robertmhaas(at)gmail(dot)com>
2010-09-03 20:20:46 from Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
2010-09-03 21:30:14 from Robert Haas <robertmhaas(at)gmail(dot)com>
2010-09-03 22:24:18 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2010-09-04 01:19:06 from Robert Haas <robertmhaas(at)gmail(dot)com>
2010-09-05 16:58:29 from Simon Riggs <simon(at)2ndQuadrant(dot)com>
2010-09-03 21:52:05 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2010-09-05 10:44:27 from Greg Stark <gsstark(at)mit(dot)edu>
2010-09-03 19:11:58 from Ron Mayer <rm_pg(at)cheapcomplexdevices(dot)com>
2010-09-03 20:17:01 from Robert Haas <robertmhaas(at)gmail(dot)com>
2010-09-03 10:50:54 from Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
2010-09-03 14:51:37 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2010-09-03 17:59:17 from Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
2010-09-03 18:16:01 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2010-09-03 18:43:23 from Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
2010-09-03 18:50:26 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2010-09-06 06:33:14 from Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
2010-09-06 14:18:04 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2010-09-06 16:27:05 from Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
2010-09-06 17:24:59 from Markus Wanner <markus(at)bluegap(dot)ch>
2010-09-06 18:46:30 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2010-09-06 20:10:57 from Markus Wanner <markus(at)bluegap(dot)ch>
2010-09-06 21:03:38 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2010-09-08 17:36:17 from Markus Wanner <markus(at)bluegap(dot)ch>
2010-09-08 18:01:01 from Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
2010-09-08 18:18:41 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2010-09-09 08:17:18 from Markus Wanner <markus(at)bluegap(dot)ch>
2010-09-09 08:34:42 from Markus Wanner <markus(at)bluegap(dot)ch>
2010-09-07 07:01:51 from Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
2010-09-07 07:06:20 from Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
2010-09-07 08:22:51 from Markus Wanner <markus(at)bluegap(dot)ch>
2010-09-08 20:07:29 from Martijn van Oosterhout <kleptog(at)svana(dot)org>
2010-09-08 20:49:29 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2010-09-09 05:32:39 from Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
2010-09-11 09:48:59 from Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
2010-09-11 15:02:45 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2010-09-11 16:15:52 from Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
2010-09-12 16:15:15 from Jeff Davis <pgsql(at)j-davis(dot)com>
2010-09-12 16:29:00 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2010-09-12 17:13:19 from Jeff Davis <pgsql(at)j-davis(dot)com>
2010-09-12 17:23:43 from Jeff Davis <pgsql(at)j-davis(dot)com>
2010-09-12 18:12:20 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2010-09-12 18:26:58 from Jeff Davis <pgsql(at)j-davis(dot)com>
2010-09-13 06:10:29 from Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
2010-09-13 17:43:16 from Jeff Davis <pgsql(at)j-davis(dot)com>
2010-09-13 18:01:49 from Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
2010-08-27 21:54:05 from Greg Smith <greg(at)2ndquadrant(dot)com>
2010-08-27 22:13:11 from Robert Haas <robertmhaas(at)gmail(dot)com>
2010-08-28 01:11:53 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2010-08-28 01:26:15 from Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
2010-08-28 01:43:36 from Greg Stark <gsstark(at)mit(dot)edu>
2010-08-28 21:00:31 from Greg Smith <greg(at)2ndquadrant(dot)com>
2010-08-31 15:40:21 from Bruce Momjian <bruce(at)momjian(dot)us>
2010-08-20 06:54:38 from tomas(at)tuxteam(dot)de
2010-08-19 15:08:38 from Alvaro Herrera <alvherre(at)commandprompt(dot)com>
2010-08-19 15:11:01 from Magnus Hagander <magnus(at)hagander(dot)net>
2010-08-19 16:16:42 from Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
Lists:
pgsql-hackers
On 31/08/10 15:47, Fujii Masao wrote:
> On Fri, Aug 27, 2010 at 4:39 PM, Fujii Masao<masao(dot)fujii(at)gmail(dot)com> wrote:
>>> /*
>>> * XXX: Should we invent an API to wait for data coming from the
>>> * client connection too? It's not critical, but we could then
>>> * eliminate the timeout altogether and go to sleep for good.
>>> */
>>
>> Yes, it would be very helpful when walsender waits for the ACK from
>> the standby in upcoming synchronous replication.
>
> I propose to change WaitLatch() so that it accepts the socket
> descriptor as an argument, to wait for data coming from the
> client connection.
Yeah, we probably should do that now.
> WaitLatch() monitors not only the self-pipe
> but also the given socket. If -1 is supplied, it checks only
> the self-pipe.
The obvious next question is how to wait for multiple sockets and a
latch at the same time? Perhaps we should have a select()-like interface
where you can pass multiple file descriptors. Then again, looking at the
current callers of select() in the backend, apart from postmaster they
all wait for only one fd.
> The socket should be monitored by using poll() if the platform
> has it, since poll() is usually more efficient.
Yeah, I guess.
> So I'd like to change Unix implementation of WaitLatch() as
> follows. Thought?
>
> -------------------
> define WaitLatch(latch, timeout) WaitLatchAndSocket(latch, -1, timeout)
>
> void WaitLatchAndSocket(Latch *latch, int sock, long timeout);
> {
> ...
>
> FD_SET(selfpipe_readfd,&input_mask);
> if (sock != -1)
> FD_SET(sock,&input_mask);
>
> #ifdef HAVE_POLL
> poll(...)
> #else
> select(...)
> #endif /* HAVE_POLL */
>
> ...
> }
> -------------------
Yep.
> Windows implementation of WaitLatchAndSocket() seems not to be
> so simple. We would need to wait for both the latch event and
> the packet from the socket by using WaitForMultipleObjectsEx().
Well, we already use WaitForMultipleObjectsEx() to implement select() on
Windows, so it should be straightforward to copy that. I'll look into that.
--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com
In response to
Responses
pgsql-hackers by date
Next :From: Pavel StehuleDate: 2010-09-01 07:30:08
Subject : Re: array_agg() NULL Handling
Previous :From : David E. WheelerDate : 2010-09-01 07:03:41
Subject : Re: array_agg() NULL Handling