Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add new configuration parameter fail_over_on_backend_error which

controls the behavior when write to backend socket fails.

Also add pool_log when postmaster administrative shutdown detected.
  • Loading branch information...
commit 037662e3cb97e47dd63949bc4c08f705a1f59ec0 1 parent 0b3b6c8
t-ishii authored
View
8 pgpool.conf.sample
@@ -1,6 +1,6 @@
#
# pgpool-II configuration file sample
-# $Header: /cvsroot/pgpool/pgpool-II/pgpool.conf.sample,v 1.28 2009/11/15 08:27:35 t-ishii Exp $
+# $Header: /cvsroot/pgpool/pgpool-II/pgpool.conf.sample,v 1.29 2009/12/06 08:46:34 t-ishii Exp $
# Host name or IP address to listen on: '*' for all, '' for no TCP/IP
# connections
@@ -120,6 +120,12 @@ failover_command = ''
#
failback_command = ''
+# If true, trigger fail over when writing to the backend communication
+# socket fails. This is the same behavior of pgpool-II 2.2.x or
+# earlier. If set to false, pgpool will report an error and disconnect
+# the session.
+fail_over_on_backend_error = true
+
# If true, automatically locks a table with INSERT statements to keep
# SERIAL data consistency. If the data does not have SERIAL data
# type, no lock will be issued. An /*INSERT LOCK*/ comment has the
View
11 pool.h
@@ -1,7 +1,7 @@
/* -*-pgsql-c-*- */
/*
*
- * $Header: /cvsroot/pgpool/pgpool-II/pool.h,v 1.46 2009/12/02 14:19:56 t-ishii Exp $
+ * $Header: /cvsroot/pgpool/pgpool-II/pool.h,v 1.47 2009/12/06 08:46:34 t-ishii Exp $
*
* pgpool: a language independent connection pool server for PostgreSQL
* written by Tatsuo Ishii
@@ -161,6 +161,15 @@ typedef struct {
char *health_check_user; /* PostgreSQL user name for health check */
char *failover_command; /* execute command when failover happens */
char *failback_command; /* execute command when failback happens */
+
+ /*
+ * If true, trigger fail over when writing to the backend
+ * communication socket fails. This is the same behavior of
+ * pgpool-II 2.2.x or earlier. If set to false, pgpool will report
+ * an error and disconnect the session.
+ */
+ int fail_over_on_backend_error;
+
char *recovery_user; /* PostgreSQL user name for online recovery */
char *recovery_password; /* PostgreSQL user password for online recovery */
char *recovery_1st_stage_command; /* Online recovery command in 1st stage */
View
17 pool_config.c
@@ -485,7 +485,7 @@ char *yytext;
/* -*-pgsql-c-*- */
/*
*
- * $Header: /cvsroot/pgpool/pgpool-II/pool_config.c,v 1.31 2009/11/15 08:27:35 t-ishii Exp $
+ * $Header: /cvsroot/pgpool/pgpool-II/pool_config.c,v 1.32 2009/12/06 08:46:34 t-ishii Exp $
*
* pgpool: a language independent connection pool server for PostgreSQL
* written by Tatsuo Ishii
@@ -1883,6 +1883,7 @@ int pool_init_config(void)
pool_config->health_check_user = "nobody";
pool_config->failover_command = "";
pool_config->failback_command = "";
+ pool_config->fail_over_on_backend_error = 1;
pool_config->insert_lock = 1;
pool_config->ignore_leading_white_space = 1;
pool_config->parallel_mode = 0;
@@ -2476,6 +2477,20 @@ int pool_get_config(char *confpath, POOL_CONFIG_CONTEXT context)
pool_config->failback_command = str;
}
+ else if (!strcmp(key, "fail_over_on_backend_error") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ int v = eval_logical(yytext);
+
+ if (v < 0)
+ {
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->fail_over_on_backend_error = v;
+ }
+
else if (!strcmp(key, "recovery_user") &&
CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
{
View
17 pool_config.l
@@ -1,7 +1,7 @@
/* -*-pgsql-c-*- */
/*
*
- * $Header: /cvsroot/pgpool/pgpool-II/pool_config.l,v 1.27 2009/11/15 08:27:35 t-ishii Exp $
+ * $Header: /cvsroot/pgpool/pgpool-II/pool_config.l,v 1.28 2009/12/06 08:46:34 t-ishii Exp $
*
* pgpool: a language independent connection pool server for PostgreSQL
* written by Tatsuo Ishii
@@ -158,6 +158,7 @@ int pool_init_config(void)
pool_config->health_check_user = "nobody";
pool_config->failover_command = "";
pool_config->failback_command = "";
+ pool_config->fail_over_on_backend_error = 1;
pool_config->insert_lock = 1;
pool_config->ignore_leading_white_space = 1;
pool_config->parallel_mode = 0;
@@ -751,6 +752,20 @@ int pool_get_config(char *confpath, POOL_CONFIG_CONTEXT context)
pool_config->failback_command = str;
}
+ else if (!strcmp(key, "fail_over_on_backend_error") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ int v = eval_logical(yytext);
+
+ if (v < 0)
+ {
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->fail_over_on_backend_error = v;
+ }
+
else if (!strcmp(key, "recovery_user") &&
CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
{
View
3  pool_process_query.c
@@ -1,6 +1,6 @@
/* -*-pgsql-c-*- */
/*
- * $Header: /cvsroot/pgpool/pgpool-II/pool_process_query.c,v 1.179 2009/12/06 07:52:49 t-ishii Exp $
+ * $Header: /cvsroot/pgpool/pgpool-II/pool_process_query.c,v 1.180 2009/12/06 08:46:34 t-ishii Exp $
*
* pgpool: a language independent connection pool server for PostgreSQL
* written by Tatsuo Ishii
@@ -282,6 +282,7 @@ POOL_STATUS pool_process_query(POOL_CONNECTION *frontend,
*/
if (detect_postmaster_down_error(CONNECTION(backend, i), MAJOR(backend)) == SPECIFIED_ERROR)
{
+ pool_log("postmaster on DB node %d was shutdown by administrative command", i);
/* detach backend node. */
was_error = 1;
if (!VALID_BACKEND(i))
View
7 pool_process_reporting.c
@@ -1,6 +1,6 @@
/* -*-pgsql-c-*- */
/*
- * $Header: /cvsroot/pgpool/pgpool-II/pool_process_reporting.c,v 1.1 2009/12/06 07:43:59 t-ishii Exp $
+ * $Header: /cvsroot/pgpool/pgpool-II/pool_process_reporting.c,v 1.2 2009/12/06 08:46:34 t-ishii Exp $
*
* pgpool: a language independent connection pool server for PostgreSQL
* written by Tatsuo Ishii
@@ -200,6 +200,11 @@ void process_reporting(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend)
strncpy(status[i].desc, "failback command", POOLCONFIG_MAXDESCLEN);
i++;
+ strncpy(status[i].name, "fail_over_on_backend_error", POOLCONFIG_MAXNAMELEN);
+ snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->insert_lock);
+ strncpy(status[i].desc, "fail_over_on_backend_error", POOLCONFIG_MAXDESCLEN);
+ i++;
+
strncpy(status[i].name, "insert_lock", POOLCONFIG_MAXNAMELEN);
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->insert_lock);
strncpy(status[i].desc, "insert lock", POOLCONFIG_MAXDESCLEN);
View
18 pool_stream.c
@@ -1,6 +1,6 @@
/* -*-pgsql-c-*- */
/*
-* $Header: /cvsroot/pgpool/pgpool-II/pool_stream.c,v 1.17 2009/11/03 01:51:46 t-ishii Exp $
+* $Header: /cvsroot/pgpool/pgpool-II/pool_stream.c,v 1.18 2009/12/06 08:46:34 t-ishii Exp $
*
* pgpool: a language independent connection pool server for PostgreSQL
* written by Tatsuo Ishii
@@ -442,10 +442,10 @@ int pool_flush_it(POOL_CONNECTION *cp)
* just report debug message.
*/
if (cp->isbackend)
- pool_error("pool_flush_it: write failed to backend (%s) offset: %d wlen: %d",
- strerror(errno), offset, wlen);
+ pool_error("pool_flush_it: write failed to backend (%d). reason: %s offset: %d wlen: %d",
+ cp->db_node_id, strerror(errno), offset, wlen);
else
- pool_debug("pool_flush_it: write failed to frontend (%s) offset: %d wlen: %d",
+ pool_debug("pool_flush_it: write failed to frontend. reason: %s offset: %d wlen: %d",
strerror(errno), offset, wlen);
cp->wbufpo = 0;
@@ -467,8 +467,14 @@ int pool_flush(POOL_CONNECTION *cp)
{
if (cp->isbackend)
{
- notice_backend_error(cp->db_node_id);
- child_exit(1);
+ /* if fail_over_on_backend_erro is true, then trigger failover */
+ if (pool_config->fail_over_on_backend_error)
+ {
+ notice_backend_error(cp->db_node_id);
+ child_exit(1);
+ }
+ else
+ return -1;
}
else
{
Please sign in to comment.
Something went wrong with that request. Please try again.