Re: Latch implementation that wakes on postmaster death on both win32 and Unix

From: Peter Geoghegan <peter(at)2ndquadrant(dot)com>
To: Florian Pflug <fgp(at)phlo(dot)org>
Cc: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Fujii Masao <masao(dot)fujii(at)gmail(dot)com>, PG Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Latch implementation that wakes on postmaster death on both win32 and Unix
Date: 2011-07-08 15:56:45
Message-ID: CAEYLb_UuDdEeHOZzH3FY5EKjbk3BabV=U0sg+nL8XBzPSpcM4A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 8 July 2011 15:58, Florian Pflug <fgp(at)phlo(dot)org> wrote:
> SyncRepWaitForLSN() says
>  /*
>   * Wait on latch for up to 60 seconds. This allows us to check for
>   * postmaster death regularly while waiting. Note that timeout here
>   * does not necessarily release from loop.
>   */
>  WaitLatch(&MyProc->waitLatch, 60000000L);
>
> I guess that 60-second timeout is unnecessary now that we'll wake up
> on postmaster death anyway.

We won't wake up on Postmaster death here, because we haven't asked to
- not yet, anyway. We're just using the new interface here for that
one function call in v8.

> Also, none of the callers of WaitLatch() seems to actually inspect
> the WL_POSTMASTER_DEATH bit of the result. We might want to make
> their !PostmasterIsAlive() check conditional on the WL_POSTMASTER_DEATH
> bit being set. At least in the case of SyncRepWaitForLSN(), it seems
> that avoiding the extra read() syscall might be beneficial.

I don't think so. Postmaster death is an anomaly, so why bother with
any sort of optimisation for that case? Also, that's exactly the sort
of thing that we're trying to caution callers against doing with this
comment:

"That should be rare in practice, but the caller should not use the
return value for anything critical, re-checking the situation with
PostmasterIsAlive() or read() on a socket if necessary."

You might say that the only reason we even bother reporting postmaster
death in the returned bitfield is because there is an expectation that
it will report it, given that we use the same masks on wakeEvents to
inform the function what events we'll actually be waiting on for the
call.

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2011-07-08 15:57:15 Re: Re: [COMMITTERS] pgsql: Adjust OLDSERXID_MAX_PAGE based on BLCKSZ.
Previous Message Robert Haas 2011-07-08 15:54:21 Re: [v9.2] Fix leaky-view problem, part 2