pgpool2.git / summary / log / commit / refs
commit 255d42631515127b4f2e2b85928cb65e7cc266e4
Author: Tatsuo Ishii <ishii at sraoss.co.jp>
Date: Sun Aug 07 09:52:47 2011 +0000
Add sr_check_period, sr_check_user and sr_check_password.
These are used for streaming replication delay checking
and determining primary server.
Also fix get_config() which forget about health_check_password.
doc/pgpool-en.html | 31 +++++++++++++++++++---
doc/pgpool-ja.html | 30 ++++++++++++++++++++--
main.c | 4 +--
pgpool.conf.sample | 9 +++++--
pgpool.conf.sample-master-slave | 9 +++++--
pgpool.conf.sample-stream | 9 +++++--
pool_config.c | 57 +++++++++++++++++++++++++++++++++++++++++
pool_config.h | 3 +++
pool_config.l | 57 +++++++++++++++++++++++++++++++++++++++++
pool_process_reporting.c | 22 +++++++++++++++-
pool_worker_child.c | 10 ++++----
11 files changed, 222 insertions(+), 19 deletions(-)
diff --git a/doc/pgpool-en.html b/doc/pgpool-en.html
index 8280a2155..3b203080d 100644
--- a/doc/pgpool-en.html
+++ b/doc/pgpool-en.html
@@ -7,7 +7,7 @@
</head>
<!-- hhmts start -->
-Last modified: Fri Aug 5 19:49:00 JST 2011
+Last modified: Sun Aug 7 18:45:28 JST 2011
<!-- hhmts end -->
<body bgcolor="#ffffff">
@@ -1641,12 +1641,37 @@ primary server in WAL bytes.
If the delay exceeds delay_threshold, pgpool-II does not send SELECT queries to
the standby server anymore. Everything is sent to the primary server
even if load balance mode is enabled, until the standby has caught-up.
-If delay_threshold is 0 or health checking is disabled, the delay
-checking is not performed. This check is performed every 'health_check_period'.
+If delay_threshold is 0 or sr checking is disabled, the delay
+checking is not performed. This check is performed every 'sr_check_period'.
The default value for delay_threshold is 0.
You need to reload pgpool.conf if you change this directive.
</p>
+<li>sr_check_period
+<p>
+This parameter specifies the interval between the streaming replication
+delay checks in seconds. Default is 0, which means the check is disabled.
+You need to reload pgpool.conf if you change sr_check_period.
+</p>
+
+<li>sr_check_user</dt>
+<p>
+The user name to perform streaming replication check. This user must
+exist in all the PostgreSQL backends. Otherwise, the check causes
+an error. Note that sr_check_user and sr_check_password are used
+even sr_check_period is 0. To identify the primary server,
+pgpool-II sends function call request to each backend.
+sr_check_user and sr_check_password are used for this session. You
+need to reload pgpool.conf if you change sr_check_user.
+</p>
+
+<li>sr_check_password</dt>
+<p>
+The password of the user to perform streaming replication check.
+If no password is required, specify empty string('').
+You need to reload pgpool.conf if you change sr_check_password.
+</p>
+
<li>log_standby_delay
<p>
Specifies how to log the replication delay.
diff --git a/doc/pgpool-ja.html b/doc/pgpool-ja.html
index 5af5edb4e..819b44928 100644
--- a/doc/pgpool-ja.html
+++ b/doc/pgpool-ja.html
@@ -8,7 +8,7 @@
<body>
<!-- hhmts start -->
-Last modified: Fri Aug 5 19:42:30 JST 2011
+Last modified: Sun Aug 7 18:45:07 JST 2011
<!-- hhmts end -->
<body bgcolor="#ffffff">
@@ -1560,11 +1560,37 @@ Streaming Replication$B$r;H$&>l9g$N?w7A$O(Bpgpool.conf.sample-stream$B$G$9!#
pgpool-II$B$O!"%9%?%s%P%$%5!<%P$NCY1d$,$3$NCM$rD6$($?>l9g$K$O!"(B
$BIi2YJ,;6$,M-8z$G$"$C$F$b$=$N(BDB$B%N!<%I$K(BSELECT$B$rAw?.$;$:!"%W%i%$%^%j%5!<%P$KAw$k$h$&$K$7$^$9!#(B
delay_threshold$B$,(B0$B$N>l9g$O!"CY1d$N%A%'%C%/$r9T$J$$$^$;$s!#(B
-$B$^$?!"(Bdelay_threshold$B$,;XDj$5$l$F$$$F$b!"%X%k%9%A%'%C%/$,L58z$J$i$P!"$d$O$j$3$N5!G=$OF/$-$^$;$s!#(B
+$B$^$?!"(Bdelay_threshold$B$,;XDj$5$l$F$$$F$b!"(Bsr_check_period$B$,L58z(B(=0)$B$J$i$P!"$d$O$j$3$N5!G=$OF/$-$^$;$s!#(B
$B%G%U%)%k%HCM$O(B0$B$G$9!#(B
$B$3$N%Q%i%a!<%?$O@_Dj%U%!%$%k$N:FFI9~$K$h$C$FJQ99$G$-$^$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B
+</p>
+
<li>log_standby_delay
<p>
$B%l%W%j%1!<%7%g%s$NCY1d>u67$r%m%0$9$k>r7o$r;XDj$7$^$9!#(B
diff --git a/main.c b/main.c
index 25a475772..2719f89a0 100644
--- a/main.c
+++ b/main.c
@@ -2494,8 +2494,8 @@ static int find_primary_node(void)
s = make_persistent_db_connection(bkinfo->backend_hostname,
bkinfo->backend_port,
"postgres",
- pool_config->health_check_user,
- "");
+ pool_config->sr_check_user,
+ pool_config->sr_check_password);
if (!s)
{
pool_error("find_primary_node: make_persistent_connection failed");
diff --git a/pgpool.conf.sample b/pgpool.conf.sample
index 9201db122..f45dc227c 100644
--- a/pgpool.conf.sample
+++ b/pgpool.conf.sample
@@ -230,10 +230,15 @@ master_slave_sub_mode = 'slony' # Master/slave sub mode
# - Streaming -
-delay_threshold = 0 # Threshold before detaching node
+sr_check_period = 0 # Streaming replication check period
+ # Disabled (0) by default
+sr_check_user = 'nobody' # Streaming replication check user
+ # This is neccessary even if you disable streaming
+ # replication delay check by sr_check_period = 0
+sr_check_password = '' # Password for streaming replication check user
+delay_threshold = 0 # Threshold before not dispatching query to standby node
# Unit is in bytes
# Disabled (0) by default
- # Health check should be enabled
# - Special commands -
diff --git a/pgpool.conf.sample-master-slave b/pgpool.conf.sample-master-slave
index 728eea2ae..f6075577a 100644
--- a/pgpool.conf.sample-master-slave
+++ b/pgpool.conf.sample-master-slave
@@ -230,10 +230,15 @@ master_slave_sub_mode = 'slony' # Master/slave sub mode
# - Streaming -
-delay_threshold = 0 # Threshold before detaching node
+sr_check_period = 0 # Streaming replication check period
+ # Disabled (0) by default
+sr_check_user = 'nobody' # Streaming replication check user
+ # This is neccessary even if you disable streaming
+ # replication delay check by sr_check_period = 0
+sr_check_password = '' # Password for streaming replication check user
+delay_threshold = 0 # Threshold before not dispatching query to standby node
# Unit is in bytes
# Disabled (0) by default
- # Health check should be enabled
# - Special commands -
diff --git a/pgpool.conf.sample-stream b/pgpool.conf.sample-stream
index 1c44f0148..1840053e3 100644
--- a/pgpool.conf.sample-stream
+++ b/pgpool.conf.sample-stream
@@ -231,10 +231,15 @@ master_slave_sub_mode = 'stream' # Master/slave sub mode
# - Streaming -
-delay_threshold = 10000000 # Threshold before detaching node
+sr_check_period = 10 # Streaming replication check period
+ # Disabled (0) by default
+sr_check_user = 'nobody' # Streaming replication check user
+ # This is neccessary even if you disable streaming
+ # replication delay check by sr_check_period = 0
+sr_check_password = '' # Password for streaming replication check user
+delay_threshold = 10000000 # Threshold before not dispatching query to standby node
# Unit is in bytes
# Disabled (0) by default
- # Health check should be enabled
# - Special commands -
diff --git a/pool_config.c b/pool_config.c
index e1e929900..86c8c7dde 100644
--- a/pool_config.c
+++ b/pool_config.c
@@ -1904,6 +1904,9 @@ int pool_init_config(void)
pool_config->health_check_period = 0;
pool_config->health_check_user = "nobody";
pool_config->health_check_password = "";
+ pool_config->sr_check_period = 0;
+ pool_config->sr_check_user = "nobody";
+ pool_config->sr_check_password = "";
pool_config->failover_command = "";
pool_config->follow_master_command = "";
pool_config->failback_command = "";
@@ -2811,6 +2814,60 @@ int pool_get_config(char *confpath, POOL_CONFIG_CONTEXT context)
pool_config->health_check_password = str;
}
+ else if (!strcmp(key, "sr_check_period") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ int v = atoi(yytext);
+
+ if (token != POOL_INTEGER || v < 0)
+ {
+ pool_error("pool_config: %s must be equal or higher than 0 numeric value", key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->sr_check_period = v;
+ }
+
+ else if (!strcmp(key, "sr_check_user") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->sr_check_user = str;
+ }
+
+ else if (!strcmp(key, "sr_check_password") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->sr_check_password = str;
+ }
+
else if (!strcmp(key, "failover_command") &&
CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
{
diff --git a/pool_config.h b/pool_config.h
index 59608672e..6a43ba36b 100644
--- a/pool_config.h
+++ b/pool_config.h
@@ -114,6 +114,9 @@ typedef struct {
int health_check_period; /* health check period */
char *health_check_user; /* PostgreSQL user name for health check */
char *health_check_password; /* password for health check username */
+ int sr_check_period; /* streming replication check period */
+ char *sr_check_user; /* PostgreSQL user name streaming replication check */
+ char *sr_check_password; /* password for sr_check_user */
char *failover_command; /* execute command when failover happens */
char *follow_master_command; /* execute command when failover is ended */
char *failback_command; /* execute command when failback happens */
diff --git a/pool_config.l b/pool_config.l
index 5a816dcaf..1785885d1 100644
--- a/pool_config.l
+++ b/pool_config.l
@@ -179,6 +179,9 @@ int pool_init_config(void)
pool_config->health_check_period = 0;
pool_config->health_check_user = "nobody";
pool_config->health_check_password = "";
+ pool_config->sr_check_period = 0;
+ pool_config->sr_check_user = "nobody";
+ pool_config->sr_check_password = "";
pool_config->failover_command = "";
pool_config->follow_master_command = "";
pool_config->failback_command = "";
@@ -1086,6 +1089,60 @@ int pool_get_config(char *confpath, POOL_CONFIG_CONTEXT context)
pool_config->health_check_password = str;
}
+ else if (!strcmp(key, "sr_check_period") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ int v = atoi(yytext);
+
+ if (token != POOL_INTEGER || v < 0)
+ {
+ pool_error("pool_config: %s must be equal or higher than 0 numeric value", key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->sr_check_period = v;
+ }
+
+ else if (!strcmp(key, "sr_check_user") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->sr_check_user = str;
+ }
+
+ else if (!strcmp(key, "sr_check_password") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->sr_check_password = str;
+ }
+
else if (!strcmp(key, "failover_command") &&
CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
{
diff --git a/pool_process_reporting.c b/pool_process_reporting.c
index c10769472..cc249e678 100644
--- a/pool_process_reporting.c
+++ b/pool_process_reporting.c
@@ -142,7 +142,7 @@ POOL_REPORT_CONFIG* get_config(int *nrows)
* In addition, we need MAX_NUM_BACKENDS*4
* for backend descriptions.
*/
-#define MAXITEMS (128 + MAX_NUM_BACKENDS*4)
+#define MAXITEMS (256 + MAX_NUM_BACKENDS*4)
POOL_REPORT_CONFIG* status = malloc(MAXITEMS * sizeof(POOL_REPORT_CONFIG));
@@ -314,6 +314,21 @@ POOL_REPORT_CONFIG* get_config(int *nrows)
strncpy(status[i].desc, "master/slave sub mode", POOLCONFIG_MAXDESCLEN);
i++;
+ strncpy(status[i].name, "sr_check_period", POOLCONFIG_MAXNAMELEN);
+ snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->sr_check_period);
+ strncpy(status[i].desc, "sr check period", POOLCONFIG_MAXDESCLEN);
+ i++;
+
+ strncpy(status[i].name, "sr_check_user", POOLCONFIG_MAXNAMELEN);
+ snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->sr_check_user);
+ strncpy(status[i].desc, "sr check user", POOLCONFIG_MAXDESCLEN);
+ i++;
+
+ strncpy(status[i].name, "sr_check_password", POOLCONFIG_MAXNAMELEN);
+ snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->sr_check_password);
+ strncpy(status[i].desc, "sr check password", POOLCONFIG_MAXDESCLEN);
+ i++;
+
strncpy(status[i].name, "delay_threshold", POOLCONFIG_MAXNAMELEN);
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%lld", pool_config->delay_threshold);
strncpy(status[i].desc, "standby delay threshold", POOLCONFIG_MAXDESCLEN);
@@ -344,6 +359,11 @@ POOL_REPORT_CONFIG* get_config(int *nrows)
strncpy(status[i].desc, "health check user", POOLCONFIG_MAXDESCLEN);
i++;
+ strncpy(status[i].name, "health_check_password", POOLCONFIG_MAXNAMELEN);
+ snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->health_check_password);
+ strncpy(status[i].desc, "health check password", POOLCONFIG_MAXDESCLEN);
+ i++;
+
strncpy(status[i].name, "failover_command", POOLCONFIG_MAXNAMELEN);
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->failover_command);
strncpy(status[i].desc, "failover command", POOLCONFIG_MAXDESCLEN);
diff --git a/pool_worker_child.c b/pool_worker_child.c
index c44fdd994..eade54338 100644
--- a/pool_worker_child.c
+++ b/pool_worker_child.c
@@ -110,7 +110,7 @@ void do_worker_child(void)
{
CHECK_REQUEST;
- if (pool_config->health_check_period <= 0)
+ if (pool_config->sr_check_period <= 0)
{
sleep(30);
}
@@ -119,7 +119,7 @@ void do_worker_child(void)
* If streaming replication mode, do time lag checking
*/
- if (pool_config->health_check_period > 0 && MASTER_SLAVE && !strcmp(pool_config->master_slave_sub_mode, MODE_STREAMREP))
+ if (pool_config->sr_check_period > 0 && MASTER_SLAVE && !strcmp(pool_config->master_slave_sub_mode, MODE_STREAMREP))
{
/* Check and establish persistent connections to the backend */
establish_persistent_connection();
@@ -130,7 +130,7 @@ void do_worker_child(void)
/* Discard persistent connections */
discard_persistent_connection();
}
- sleep(pool_config->health_check_period);
+ sleep(pool_config->sr_check_period);
}
exit(0);
}
@@ -155,8 +155,8 @@ static void establish_persistent_connection(void)
s = make_persistent_db_connection(bkinfo->backend_hostname,
bkinfo->backend_port,
"postgres",
- pool_config->health_check_user,
- pool_config->health_check_password);
+ pool_config->sr_check_user,
+ pool_config->sr_check_password);
if (s)
slots[i] = s;
else
[parent: 39f35632c78b]