pgpool2.git / summary / log / commit / refs
commit 0b178eecfd127cc1e39b79618a10954296b7ee3d
Author: Yoshiyuki Asaba <y-asaba at pgfoundry.org>
Date: Fri Sep 14 11:11:54 2007 +0000
Fix hang up when load balancing node was down.
child.c | 3 +--
pool.h | 1 +
pool_process_query.c | 10 ++++++++++
3 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/child.c b/child.c
index 7538b1b92..fdac154d9 100644
--- a/child.c
+++ b/child.c
@@ -66,7 +66,6 @@ static RETSIGTYPE reload_config_handler(int sig);
static int send_params(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend);
static void send_frontend_exits(void);
static int s_do_auth(POOL_CONNECTION_POOL_SLOT *cp, char *password);
-static int select_load_balancing_node(void);
/*
* non 0 means SIGTERM(smart shutdown) or SIGINT(fast shutdown) has arrived
@@ -1710,7 +1709,7 @@ static RETSIGTYPE wakeup_handler(int sig)
/*
* Select load balancing node
*/
-static int select_load_balancing_node(void)
+int select_load_balancing_node(void)
{
double total_weight,r;
int i;
diff --git a/pool.h b/pool.h
index cd984b7ae..3bd40b756 100644
--- a/pool.h
+++ b/pool.h
@@ -402,6 +402,7 @@ extern int pool_init_config(void);
extern int pool_get_config(char *confpath, POOL_CONFIG_CONTEXT context);
extern void do_child(int unix_fd, int inet_fd);
extern void pcp_do_child(int unix_fd, int inet_fd, char *pcp_conf_file);
+extern int select_load_balancing_node(void);
extern int pool_init_cp(void);
extern POOL_STATUS pool_process_query(POOL_CONNECTION *frontend,
POOL_CONNECTION_POOL *backend,
diff --git a/pool_process_query.c b/pool_process_query.c
index a6e1974d5..e6fb054c8 100644
--- a/pool_process_query.c
+++ b/pool_process_query.c
@@ -298,6 +298,12 @@ POOL_STATUS pool_process_query(POOL_CONNECTION *frontend,
num_fds = 0;
+ if (!VALID_BACKEND(backend->info->load_balancing_node))
+ {
+ /* select load balancing node */
+ backend->info->load_balancing_node = select_load_balancing_node();
+ }
+
for (i=0;i<NUM_BACKENDS;i++)
{
if (VALID_BACKEND(i))
@@ -337,6 +343,8 @@ POOL_STATUS pool_process_query(POOL_CONNECTION *frontend,
if (detect_postmaster_down_error(CONNECTION(backend, i), MAJOR(backend)))
{
was_error = 1;
+ if (!VALID_BACKEND(i))
+ break;
notice_backend_error(i);
sleep(5);
break;
@@ -364,6 +372,8 @@ POOL_STATUS pool_process_query(POOL_CONNECTION *frontend,
continue;
}
+ if (kind == 0)
+ continue;
}
if (FD_ISSET(MASTER(backend)->fd, &exceptmask))
[parent: d71782dc1f7f]