On Wed, Jun 22, 2011 at 9:11 PM, Peter Geoghegan <pe...@2ndquadrant.com> wrote: >> rc = WaitForMultipleObjects(numevents, events, FALSE, >> (timeout >= 0) ? >> (timeout / 1000) : INFINITE); >> - if (rc == WAIT_FAILED) >> + if ( (wakeEvents & WL_POSTMASTER_DEATH) && >> + !PostmasterIsAlive(true)) >> >> After WaitForMultipleObjects() detects the death of postmaster, >> WaitForSingleObject() >> is called in PostmasterIsAlive(). In this case, what code does >> WaitForSingleObject() return? >> I wonder if WaitForSingleObject() returns the code other than >> WAIT_TIMEOUT and really >> can detect the death of postmaster. > > As noted up-thread, the fact that the archiver does wake and finish on > Postmaster death can be clearly observed on Windows. I'm not sure why > you wonder that, as this is fairly standard use of > PostmasterIsAlive().
Because, if PostmasterHandle is an auto-reset event object, its event state would be automatically reset just after WaitForMultipleObjects() detects the postmaster death event, I was afraid. But your observation proved that my concern was not right. I have another comments: +#ifndef WIN32 + /* + * Initialise mechanism that allows waiting latch clients + * to wake on postmaster death, to finish their + * remaining business + */ + InitPostmasterDeathWatchHandle(); +#endif Calling this function before creating TopMemoryContext looks unsafe. What if the function calls ereport(FATAL)? That ereport() can be called before postgresql.conf is read, i.e., before GUCs for error reporting are set. Is this OK? If not, InitPostmasterDeathWatchHandle() should be moved after SelectConfigFiles(). +#ifndef WIN32 +int postmaster_alive_fds[2]; +#endif postmaster_alive_fds[] should be initialized to "{-1, -1}"? Regards, -- Fujii Masao NIPPON TELEGRAPH AND TELEPHONE CORPORATION NTT Open Source Software Center -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers