Thread: pgsql: Make WaitLatch's WL_POSTMASTER_DEATH result trustworthy; simplif

Make WaitLatch's WL_POSTMASTER_DEATH result trustworthy; simplify callers.

Per a suggestion from Peter Geoghegan, make WaitLatch responsible for
verifying that the WL_POSTMASTER_DEATH bit it returns is truthful (by
testing PostmasterIsAlive).  Then simplify its callers, who no longer
need to do that for themselves.  Remove weasel wording about falsely-set
result bits from WaitLatch's API contract.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/f40022f1adaeff85b01d98fea38cf5aa16814aa7

Modified Files
--------------
src/backend/port/unix_latch.c         |   35 ++++++++++++++++++++++----------
src/backend/port/win32_latch.c        |   12 +++++++++-
src/backend/postmaster/autovacuum.c   |    9 ++++---
src/backend/postmaster/bgwriter.c     |    7 +----
src/backend/postmaster/checkpointer.c |    7 +----
src/backend/postmaster/pgstat.c       |    7 +----
src/backend/postmaster/walwriter.c    |    7 +----
7 files changed, 47 insertions(+), 37 deletions(-)


Re: pgsql: Make WaitLatch's WL_POSTMASTER_DEATH result trustworthy; simplif

From
Peter Geoghegan
Date:
On 10 May 2012 19:35, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Remove weasel wording about falsely-set result bits from
> WaitLatch's API contract.

Aren't those weasel words still applicable to the case where sock !=
PGINVALID_SOCKET ?

--
Peter Geoghegan       http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training and Services

Peter Geoghegan <peter@2ndquadrant.com> writes:
> On 10 May 2012 19:35, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Remove weasel wording about falsely-set result bits from
>> WaitLatch's API contract.

> Aren't those weasel words still applicable to the case where sock !=
> PGINVALID_SOCKET ?

I don't think so.  WaitLatch is honestly reporting the result of select
or poll; code that doesn't work with it wouldn't work with the native
OS facilities either.  The only case that is really a problem here is
where we make the logical leap from "socket possibly readable" to
"postmaster is dead".

I think what that Linux man page is advising is that you not assume that
a blocking-mode read() won't block, which AFAIK is something we don't
do; we always use non-block mode on sockets we don't wish to block on.

            regards, tom lane