From:
Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To:
Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc:
Fujii Masao <masao(dot)fujii(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject:
Re: Interruptible sleeps (was Re: CommitFest 2009-07: Yay,
Kevin! Thanks, reviewers!)
Date:
2010-09-03 10:50:54
Message-ID:
4C80D30E.2010504@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 02/09/10 23:13, Tom Lane wrote:
> The WaitLatch ...timeout API could use a bit of refinement. I'd suggest
> defining negative timeout as meaning wait forever, so that timeout = 0
> can be used for "check but don't wait". Also, it seems like the
> function shouldn't just return void but should return a bool to show
> whether it saw the latch set or timed out.
In case of WaitLatchOrSocket, the caller might want to know if a latch
was set, the socket became readable, or it timed out. So we need three
different return values.
> (Yeah, I realize the caller
> could look into the latch to find that out, but callers really ought to
> treat latches as opaque structs.)
Hmm, maybe we need a TestLatch function to check if a latch is set.
> I don't think you have the select-failed logic right in
> WaitLatchOrSocket; on EINTR it will suppose that FD_ISSET is a valid
> test to make, which I think ain't the case. Just "continue" around
> the loop.
Yep.
I also realized that the timeout handling is a bit surprising with
interrupts. After EINTR we call select() again with the same timeout, so
a signal effectively restarts the timer. We seem to have similar
behavior in a couple of other places, in pgstat.c and auth.c. So maybe
that's OK and just needs to be documented, but I thought I'd bring it up.
> It seems like both implementations are #include'ing more than they
> ought to --- why replication/walsender.h, in particular?
Windows implementation needs it for the max_wal_senders variable, to
allocate enough shared Event objects in LatchShmemInit. In unix_latch.c
it's not needed.
> Also, using sig_atomic_t for owner_pid is entirely not sane.
> On many platforms sig_atomic_t is only a byte, and besides
> which you have no need for that field to be settable by a
> signal handler.
Hmm, true, it doesn't need to be set from signal handler, but is there
an atomicity problem if one process calls ReleaseLatch while another
process is in SetLatch? ReleaseLatch sets owner_pid to 0, while SetLatch
reads it and calls kill() on it. Can we assume that pid_t is atomic, or
do we need a spinlock to protect it? (Windows implementation has a
similar issue with HANDLE instead of pid_t)
--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com
In response to
Responses
pgsql-hackers by date
Next :From: Heikki LinnakangasDate: 2010-09-03 11:00:31
Subject : Re: thousand unrelated data files in pg_default tablespace
Previous :From : Heikki LinnakangasDate : 2010-09-03 10:31:07
Subject : Re: Synchronous replication - patch status inquiry