pgpool2.git / summary / log / commit / refs
commit f92807012d92d0791913e75beef8c66f1a57780b
Author: Tatsuo Ishii <ishii at sraoss.co.jp>
Date: Wed May 12 04:58:13 2010 +0000
Add new directive "debug_level" to be able to turn on/off debug
messages on the fly. Although it is possible to assign 1 more integer
to specify vervosity, currently there is no infrastracture to make it
reality. Probably we will add new api pool_debug2, pool_debug3... for
this purpose later on.
Also I make the debug message control global variable "debug" for pcp
commands only. This means pgpool -d does not show debug messages from
pcp anymore. This is neccessary to prevengt from generating
meaningless, annoying debug messages by pcp when health checking is
turned on. It might be worth to add another command option to pgpool
so that pcp generates debug messages, but I'm not sure.
doc/pgpool-en.html | 11 ++++++++++-
doc/pgpool-ja.html | 11 ++++++++++-
main.c | 17 +++++++++++------
pgpool.conf.sample | 3 +++
pgpool.conf.sample-master-slave | 3 +++
pgpool.conf.sample-replication | 3 +++
pool.h | 5 +++++
pool_config.c | 14 ++++++++++++++
pool_config.l | 14 ++++++++++++++
pool_error.c | 10 +++++++---
pool_process_reporting.c | 5 +++++
11 files changed, 85 insertions(+), 11 deletions(-)
diff --git a/doc/pgpool-en.html b/doc/pgpool-en.html
index 85277f4d5..d698223f3 100644
--- a/doc/pgpool-en.html
+++ b/doc/pgpool-en.html
@@ -7,7 +7,7 @@
</head>
<!-- hhmts start -->
-Last modified: Sun Apr 18 21:23:43 JST 2010
+Last modified: Wed May 12 13:43:25 JST 2010
<!-- hhmts end -->
<body bgcolor="#ffffff">
@@ -718,6 +718,15 @@ You need to reload pgpool.conf if you change the value.
be disabled for incoming frontend connections.
</p>
</dd>
+
+ <dt>debug_level</dt>
+ <dd>
+ <p>
+ Debug message verbosity level. 0 measn no message, greater than 1
+ means more verbose message. Default value is 0.
+ </p>
+ </dd>
+
</dl>
</dl>
diff --git a/doc/pgpool-ja.html b/doc/pgpool-ja.html
index 88327d7cd..54ec574e1 100644
--- a/doc/pgpool-ja.html
+++ b/doc/pgpool-ja.html
@@ -8,7 +8,7 @@
<body>
<!-- hhmts start -->
-Last modified: Sun Apr 18 18:24:48 JST 2010
+Last modified: Wed May 12 13:45:32 JST 2010
<!-- hhmts end -->
<body bgcolor="#ffffff">
@@ -683,6 +683,15 @@ backend_data_directory $B$O?7$7$/DI2C$7$?9T$r@_Dj%U%!%$%k:FFI$_9~$_$GDI2C$9$k(
ssl_cert$B$N%G%U%)%k%HCM$O$"$j$^$;$s!#(B
ssl_cert$B$N@_Dj$,$J$$>l9g$O!"%U%m%s%H%(%s%I$H$N@\B3$G(BSSL$B$,;HMQ$5$l$J$/$J$j$^$9!#(B
</p>
+
+ <dt>debug_level</dt>
+ <dd>
+ <p>
+ $B%G%P%C%0%a%C%;!<%8$N>\:Y%l%Y%k!#(B0$B$G%G%P%C%0%a%C%;!<%8$N=PNO$J$7!#(B
+ 1$B0J>e$G%G%P%C%0%a%C%;!<%8$r=PNO$7$^$9!#(B
+ $B?t;z$,Bg$-$1$l$P$h$j>\:Y$J%a%C%;!<%8$,=PNO$5$l$k$h$&$K$J$j$^$9!#(B
+ $B%G%U%)%k%HCM$O(B0$B$G$9!#(B
+ </p>
</dd>
</dl>
diff --git a/main.c b/main.c
index c285db9c6..3ce8867bd 100644
--- a/main.c
+++ b/main.c
@@ -138,13 +138,9 @@ static char hba_file[POOLMAXPATHLEN+1];
static int exiting = 0; /* non 0 if I'm exiting */
static int switching = 0; /* non 0 if I'm fail overing or degenerating */
-#ifdef NOT_USED
-static int degenerated = 0; /* set non 0 if already degenerated */
-#endif
-
static int clear_cache = 0; /* non 0 if clear chache option (-c) is given */
static int not_detach = 0; /* non 0 if non detach option (-n) is given */
-int debug = 0; /* non 0 if debug option is given (-d) */
+int debug = 0; /* non 0 if debug option is given (-d). pcp only */
pid_t mypid; /* pgpool parent process id */
@@ -164,6 +160,7 @@ static volatile sig_atomic_t wakeup_request = 0;
static int pipe_fds[2]; /* for delivering signals */
int my_proc_id;
+bool run_as_pcp_child;
static BackendStatusRecord backend_rec; /* Backend status record */
@@ -181,6 +178,7 @@ int main(int argc, char **argv)
int size;
int retrycnt;
int sys_retrycnt;
+ int debug_level = 0;
myargc = argc;
myargv = argv;
@@ -207,7 +205,7 @@ int main(int argc, char **argv)
break;
case 'd': /* debug option */
- debug = 1;
+ debug_level = 1;
break;
case 'f': /* specify configuration file */
@@ -283,6 +281,11 @@ int main(int argc, char **argv)
exit(1);
}
+ /*
+ * Override debug level
+ */
+ pool_config->debug_level = debug_level;
+
if (pool_config->enable_pool_hba)
load_hba(hba_file);
@@ -902,6 +905,7 @@ pid_t pcp_fork_a_child(int unix_fd, int inet_fd, char *pcp_conf_file)
/* call PCP child main */
POOL_SETMASK(&UnBlockSig);
reload_config_request = 0;
+ run_as_pcp_child = true;
pcp_do_child(unix_fd, inet_fd, pcp_conf_file);
}
else if (pid == -1)
@@ -943,6 +947,7 @@ pid_t fork_a_child(int unix_fd, int inet_fd, int id)
POOL_SETMASK(&UnBlockSig);
reload_config_request = 0;
my_proc_id = id;
+ run_as_pcp_child = false;
do_child(unix_fd, inet_fd);
}
else if (pid == -1)
diff --git a/pgpool.conf.sample b/pgpool.conf.sample
index ed2f3af43..f7fe59d86 100644
--- a/pgpool.conf.sample
+++ b/pgpool.conf.sample
@@ -238,3 +238,6 @@ ssl = false
# -CAfile and -CApath options to openssl verify(1), respectively.
#ssl_ca_cert = ''
#ssl_ca_cert_dir = ''
+
+# Debug message verbosity level. 0: no message, 1 <= : more verbose
+debug_level = 0
diff --git a/pgpool.conf.sample-master-slave b/pgpool.conf.sample-master-slave
index 048614784..fcefa3d75 100644
--- a/pgpool.conf.sample-master-slave
+++ b/pgpool.conf.sample-master-slave
@@ -238,3 +238,6 @@ ssl = false
# -CAfile and -CApath options to openssl verify(1), respectively.
#ssl_ca_cert = ''
#ssl_ca_cert_dir = ''
+
+# Debug message verbosity level. 0: no message, 1 <= : more verbose
+debug_level = 0
diff --git a/pgpool.conf.sample-replication b/pgpool.conf.sample-replication
index 41b8bdef4..373560a38 100644
--- a/pgpool.conf.sample-replication
+++ b/pgpool.conf.sample-replication
@@ -238,3 +238,6 @@ ssl = false
# -CAfile and -CApath options to openssl verify(1), respectively.
#ssl_ca_cert = ''
#ssl_ca_cert_dir = ''
+
+# Debug message verbosity level. 0: no message, 1 <= : more verbose
+debug_level = 0
diff --git a/pool.h b/pool.h
index d2340855b..51b0248b3 100644
--- a/pool.h
+++ b/pool.h
@@ -207,6 +207,10 @@ typedef struct {
char *lobj_lock_table; /* table name to lock for rewriting lo_creat */
+ int debug_level; /* debug message verbosity level.
+ * 0: no message, 1 <= : more verbose
+ */
+
BackendDesc *backend_desc; /* PostgreSQL Server description. Placed on shared memory */
LOAD_BALANCE_STATUS load_balance_status[MAX_NUM_BACKENDS]; /* to remember which DB node is selected for load balancing */
@@ -483,6 +487,7 @@ typedef struct {
* global variables
*/
extern pid_t mypid; /* parent pid */
+extern bool run_as_pcp_child;
extern POOL_CONFIG *pool_config; /* configuration values */
extern POOL_CONNECTION_POOL *pool_connection_pool; /* connection pool */
extern volatile sig_atomic_t backend_timer_expired; /* flag for connection closed timer is expired */
diff --git a/pool_config.c b/pool_config.c
index be669f54a..e42704bea 100644
--- a/pool_config.c
+++ b/pool_config.c
@@ -1907,6 +1907,7 @@ int pool_init_config(void)
pool_config->ssl_key = "";
pool_config->ssl_ca_cert = "";
pool_config->ssl_ca_cert_dir = "";
+ pool_config->debug_level = 0;
res = gethostname(localhostname,sizeof(localhostname));
if(res !=0 )
@@ -3048,6 +3049,19 @@ int pool_get_config(char *confpath, POOL_CONFIG_CONTEXT context)
}
pool_config->ssl_ca_cert_dir = str;
}
+
+ else if (!strcmp(key, "debug_level") && 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->debug_level = v;
+ }
}
fclose(fd);
diff --git a/pool_config.l b/pool_config.l
index 4bc36a15c..f2494ee47 100644
--- a/pool_config.l
+++ b/pool_config.l
@@ -182,6 +182,7 @@ int pool_init_config(void)
pool_config->ssl_key = "";
pool_config->ssl_ca_cert = "";
pool_config->ssl_ca_cert_dir = "";
+ pool_config->debug_level = 0;
res = gethostname(localhostname,sizeof(localhostname));
if(res !=0 )
@@ -1323,6 +1324,19 @@ int pool_get_config(char *confpath, POOL_CONFIG_CONTEXT context)
}
pool_config->ssl_ca_cert_dir = str;
}
+
+ else if (!strcmp(key, "debug_level") && 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->debug_level = v;
+ }
}
fclose(fd);
diff --git a/pool_error.c b/pool_error.c
index bf7a7093b..02cb93934 100644
--- a/pool_error.c
+++ b/pool_error.c
@@ -5,7 +5,7 @@
* pgpool: a language independent connection pool server for PostgreSQL
* written by Tatsuo Ishii
*
- * Copyright (c) 2003-2008 PgPool Global Development Group
+ * Copyright (c) 2003-2010 PgPool Global Development Group
*
* Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose and without fee is hereby
@@ -92,8 +92,12 @@ void pool_debug(const char *fmt,...)
int oldmask;
#endif
- if (!debug)
- return;
+ if (run_as_pcp_child)
+ if (!debug)
+ return;
+ else
+ if (pool_config->debug_level <= 0)
+ return;
POOL_SETMASK2(&BlockSig, &oldmask);
diff --git a/pool_process_reporting.c b/pool_process_reporting.c
index 61b0a9521..dbb0c0054 100644
--- a/pool_process_reporting.c
+++ b/pool_process_reporting.c
@@ -326,6 +326,11 @@ void process_reporting(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend)
strncpy(status[i].desc, "path to the SSL public certificate file", POOLCONFIG_MAXDESCLEN);
i++;
+ strncpy(status[i].name, "debug_level", POOLCONFIG_MAXNAMELEN);
+ snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->debug_level);
+ strncpy(status[i].desc, "debug message level", POOLCONFIG_MAXDESCLEN);
+ i++;
+
strncpy(status[i].name, "parallel_mode", POOLCONFIG_MAXNAMELEN);
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->parallel_mode);
strncpy(status[i].desc, "if non 0, run in parallel query mode", POOLCONFIG_MAXDESCLEN);
[parent: 8371f05241e1]