pgpool2.git / summary / log / commit / refs
commit 28f8b2930bfb97bdd4378503f7ba8c8fff90fafe
Author: Tatsuo Ishii <ishii at sraoss.co.jp>
Date: Wed Feb 23 06:47:48 2011 +0000
Do not keep persistent connection to backends.
The connection may become bogus if a node down and then wake up
between replication delay checking period.
Restarting worker process is not feasible since there is a time lang
between backend down and restarting worker process.
pool_worker_child.c | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/pool_worker_child.c b/pool_worker_child.c
index 916042f62..612cedaee 100644
--- a/pool_worker_child.c
+++ b/pool_worker_child.c
@@ -5,7 +5,7 @@
* pgpool: a language independent connection pool server for PostgreSQL
* written by Tatsuo Ishii
*
- * Copyright (c) 2003-2010 PgPool Global Development Group
+ * Copyright (c) 2003-2011 PgPool Global Development Group
*
* Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose and without fee is hereby
@@ -65,6 +65,7 @@ static POOL_CONNECTION_POOL_SLOT *slots[MAX_NUM_BACKENDS];
static volatile sig_atomic_t reload_config_request = 0;
static void establish_persistent_connection(void);
+static void discard_persistent_connection(void);
static void check_replication_time_lag(void);
static long text_to_lsn(char *text);
static RETSIGTYPE my_signal_handler(int sig);
@@ -125,6 +126,9 @@ void do_worker_child(void)
/* Do replication time lag checking */
check_replication_time_lag();
+
+ /* Discard persistent connections */
+ discard_persistent_connection();
}
sleep(pool_config->health_check_period);
}
@@ -161,6 +165,23 @@ static void establish_persistent_connection(void)
}
}
+/*
+ * Discard persistent connection to backend
+ */
+static void discard_persistent_connection(void)
+{
+ int i;
+
+ for (i=0;i<NUM_BACKENDS;i++)
+ {
+ if (slots[i])
+ {
+ discard_persistent_db_connection(slots[i]);
+ slots[i] = NULL;
+ }
+ }
+}
+
/*
* Check replicaton time lag
*/
@@ -219,7 +240,6 @@ static void check_replication_time_lag(void)
if (sts != POOL_CONTINUE)
{
pool_error("check_replication_time_lag: %s failed", query);
- slots[i] = NULL;
return;
}
if (!res)
[parent: b925dd1444f4]