pgpool2.git / summary / log / commit / refs
commit 294cf4aa4d5a3b9489d33b29d04a5ea9b8cf6d89
Author: Yugo Nagata <nagata@sraoss.co.jp>
Date: Wed Jun 08 11:59:03 2016 +0000
Fix a posible hang during health checking
Helath checking was hang when any data wasn't sent
from backend after connect(2) succeeded. To fix this,
pool_check_fd() returns 1 when select(2) exits with
EINTR due to SIGALRM while health checkking is performed.
Reported and patch provided by harukat and some modification
by Yugo. Per bug #204.
src/protocol/pool_process_query.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/src/protocol/pool_process_query.c b/src/protocol/pool_process_query.c
index 93ea5c3ea..95aba34a0 100644
--- a/src/protocol/pool_process_query.c
+++ b/src/protocol/pool_process_query.c
@@ -606,6 +606,7 @@ int pool_check_fd(POOL_CONNECTION *cp)
int fds;
struct timeval timeout;
struct timeval *timeoutp;
+ int save_errno;
/*
* If SSL is enabled, we need to check SSL internal buffer
@@ -635,8 +636,16 @@ int pool_check_fd(POOL_CONNECTION *cp)
FD_SET(fd, &exceptmask);
fds = select(fd+1, &readmask, NULL, &exceptmask, timeoutp);
+ save_errno = errno;
if (fds == -1)
{
+ if (processState == PERFORMING_HEALTH_CHECK && errno == EINTR)
+ {
+ ereport(WARNING, (errmsg("health check timed out while waiting for reading data")));
+ errno = save_errno;
+ return 1;
+ }
+
if (errno == EAGAIN || errno == EINTR)
continue;
@@ -653,6 +662,7 @@ int pool_check_fd(POOL_CONNECTION *cp)
(errmsg("waiting for reading data. exception occurred in select ")));
break;
}
+ errno = save_errno;
return 0;
}
return -1;
[parent: 3d1092d8f166]