mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-06 15:24:56 +08:00
In pgstat.c, use a timeout in WaitLatchOrSocket only on Windows.
We have no need for a timeout here really, but some broken products from Redmond seem to lose FD_READ events occasionally, and waking up and retrying the recv() is the only known way to work around that. Perhaps somebody will be motivated to figure out a better answer here; but not I.
This commit is contained in:
parent
5a2bb06012
commit
9b63e9869f
@ -3113,7 +3113,8 @@ PgstatCollectorMain(int argc, char *argv[])
|
|||||||
* Try to receive and process a message. This will not block,
|
* Try to receive and process a message. This will not block,
|
||||||
* since the socket is set to non-blocking mode.
|
* since the socket is set to non-blocking mode.
|
||||||
*
|
*
|
||||||
* XXX On Windows, we have to force pgwin32_recv to cooperate.
|
* XXX On Windows, we have to force pgwin32_recv to cooperate,
|
||||||
|
* despite the previous use of pg_set_noblock() on the socket.
|
||||||
* This is extremely broken and should be fixed someday.
|
* This is extremely broken and should be fixed someday.
|
||||||
*/
|
*/
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
@ -3231,11 +3232,27 @@ PgstatCollectorMain(int argc, char *argv[])
|
|||||||
} /* end of inner message-processing loop */
|
} /* end of inner message-processing loop */
|
||||||
|
|
||||||
/* Sleep until there's something to do */
|
/* Sleep until there's something to do */
|
||||||
/* XXX should not need a timeout here */
|
#ifndef WIN32
|
||||||
|
wr = WaitLatchOrSocket(&pgStatLatch,
|
||||||
|
WL_LATCH_SET | WL_POSTMASTER_DEATH | WL_SOCKET_READABLE,
|
||||||
|
pgStatSock,
|
||||||
|
-1L);
|
||||||
|
#else
|
||||||
|
/*
|
||||||
|
* Windows, at least in its Windows Server 2003 R2 incarnation,
|
||||||
|
* sometimes loses FD_READ events. Waking up and retrying the recv()
|
||||||
|
* fixes that, so don't sleep indefinitely. This is a crock of the
|
||||||
|
* first water, but until somebody wants to debug exactly what's
|
||||||
|
* happening there, this is the best we can do. The two-second
|
||||||
|
* timeout matches our pre-9.2 behavior, and needs to be short enough
|
||||||
|
* to not provoke "pgstat wait timeout" complaints from
|
||||||
|
* backend_read_statsfile.
|
||||||
|
*/
|
||||||
wr = WaitLatchOrSocket(&pgStatLatch,
|
wr = WaitLatchOrSocket(&pgStatLatch,
|
||||||
WL_LATCH_SET | WL_POSTMASTER_DEATH | WL_SOCKET_READABLE | WL_TIMEOUT,
|
WL_LATCH_SET | WL_POSTMASTER_DEATH | WL_SOCKET_READABLE | WL_TIMEOUT,
|
||||||
pgStatSock,
|
pgStatSock,
|
||||||
2000L);
|
2 * 1000L /* msec */);
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Emergency bailout if postmaster has died. This is to avoid the
|
* Emergency bailout if postmaster has died. This is to avoid the
|
||||||
|
Loading…
Reference in New Issue
Block a user