pgpool2.git / summary / log / commit / refs
commit 84d66997dedb9f2e203da4f094fbecdec2ec16ba
Author: Tatsuo Ishii <ishii@sraoss.co.jp>
Date: Sat Apr 15 02:59:43 2023 +0000
Add new config parameter "log_pcp_processes",
This allows to disable logging about normal PCP Process fork and exit
status. When pcp command is executed, pgpool logs its fork/exit event
even if there's no error. This could fill up the pgpool log.
Abnormal fork/exit event will be logged even if the parameter is
disabled.
Author: Maximilien Cuony
Review and Japanese document by: Tatsuo Ishii
doc.ja/src/sgml/connection-pooling.sgml | 27 +++++++++++++++++++++++++++
doc/src/sgml/connection-pooling.sgml | 17 +++++++++++++++++
src/config/pool_config_variables.c | 10 ++++++++++
src/include/pool_config.h | 1 +
src/pcp_con/pcp_child.c | 14 ++++++++------
src/sample/pgpool.conf.sample-stream | 2 ++
src/utils/pool_process_reporting.c | 5 +++++
7 files changed, 70 insertions(+), 6 deletions(-)
diff --git a/doc.ja/src/sgml/connection-pooling.sgml b/doc.ja/src/sgml/connection-pooling.sgml
index 64e2fb98b..d7bec36bb 100644
--- a/doc.ja/src/sgml/connection-pooling.sgml
+++ b/doc.ja/src/sgml/connection-pooling.sgml
@@ -1284,6 +1284,33 @@ local0.* /var/log/pgpool.log
</listitem>
</varlistentry>
+ <varlistentry id="guc-log-pcp-processes" xreflabel="log_pcp_processes">
+ <term><varname>log_pcp_processes</varname> (<type>boolean</type>)
+ <indexterm>
+ <!--
+ <primary><varname>log_pcp_processes</varname> configuration parameter</primary>
+ -->
+ <primary><varname>log_pcp_processes</varname> 設定パラメータ</primary>
+ </indexterm>
+ </term>
+ <listitem>
+ <para>
+ <!--
+ Setting to on, enable logging about normal PCP Process
+ fork and exit statues. Default is on.
+ -->
+ onに設定されている場合、PCPプロセスの正常なforkあるいはexitした状態をログに出力します。
+ デフォルトはonです。
+ </para>
+ <para>
+ <!--
+ This parameter can be changed by reloading the <productname>Pgpool-II</> configurations.
+ -->
+ このパラメータは<productname>Pgpool-II</>の設定を再読み込みすることで変更可能です。
+ </para>
+ </listitem>
+ </varlistentry>
+
<varlistentry id="guc-log-error-verbosity" xreflabel="log_error_verbosity">
<term><varname>log_error_verbosity</varname> (<type>enum</type>)
<indexterm>
diff --git a/doc/src/sgml/connection-pooling.sgml b/doc/src/sgml/connection-pooling.sgml
index 9b376329e..28dcb4a36 100644
--- a/doc/src/sgml/connection-pooling.sgml
+++ b/doc/src/sgml/connection-pooling.sgml
@@ -827,6 +827,23 @@
</listitem>
</varlistentry>
+ <varlistentry id="guc-log-pcp-processes" xreflabel="log_pcp_processes">
+ <term><varname>log_pcp_processes</varname> (<type>boolean</type>)
+ <indexterm>
+ <primary><varname>log_pcp_processes</varname> configuration parameter</primary>
+ </indexterm>
+ </term>
+ <listitem>
+ <para>
+ Setting to on, enable logging about normal PCP Process
+ fork and exit statues. Default is on.
+ </para>
+ <para>
+ This parameter can be changed by reloading the <productname>Pgpool-II</> configurations.
+ </para>
+ </listitem>
+ </varlistentry>
+
<varlistentry id="guc-log-error-verbosity" xreflabel="log_error_verbosity">
<term><varname>log_error_verbosity</varname> (<type>enum</type>)
<indexterm>
diff --git a/src/config/pool_config_variables.c b/src/config/pool_config_variables.c
index 38de1d05a..9fb53c17e 100644
--- a/src/config/pool_config_variables.c
+++ b/src/config/pool_config_variables.c
@@ -463,6 +463,16 @@ static struct config_bool ConfigureNamesBool[] =
NULL, NULL, NULL
},
+ {
+ {"log_pcp_processes", CFGCXT_RELOAD, LOGGING_CONFIG,
+ "Logs PCP process forks and anormal exit status to the log",
+ CONFIG_VAR_TYPE_BOOL, false, 0
+ },
+ &g_pool_config.log_pcp_processes,
+ true,
+ NULL, NULL, NULL
+ },
+
{
{"log_hostname", CFGCXT_RELOAD, LOGGING_CONFIG,
"Logs the host name in the connection logs.",
diff --git a/src/include/pool_config.h b/src/include/pool_config.h
index 4a9b2133d..50ffb3389 100644
--- a/src/include/pool_config.h
+++ b/src/include/pool_config.h
@@ -264,6 +264,7 @@ typedef struct
bool replication_mode; /* replication mode */
bool log_connections; /* logs incoming connections */
bool log_disconnections; /* logs closing connections */
+ bool log_pcp_processes; /* logs pcp processes */
bool log_hostname; /* resolve hostname */
bool enable_pool_hba; /* enables pool_hba.conf file
* authentication */
diff --git a/src/pcp_con/pcp_child.c b/src/pcp_con/pcp_child.c
index 1b81f7030..6c3f87092 100644
--- a/src/pcp_con/pcp_child.c
+++ b/src/pcp_con/pcp_child.c
@@ -303,9 +303,10 @@ start_pcp_command_processor_process(int port, int *fds)
}
else /* parent */
{
- ereport(LOG,
- (errmsg("forked new pcp worker, pid=%d socket=%d",
- (int) pid, (int) port)));
+ if (pool_config->log_pcp_processes)
+ ereport(LOG,
+ (errmsg("forked new pcp worker, pid=%d socket=%d",
+ (int) pid, (int) port)));
/* close the port in parent process. It is only consumed by child */
close(port);
/* Add it to the list */
@@ -359,7 +360,7 @@ reaper(void)
if (WEXITSTATUS(status) == POOL_EXIT_FATAL)
ereport(LOG,
(errmsg("PCP worker process with pid: %d exit with FATAL ERROR.", pid)));
- else
+ else if (pool_config->log_pcp_processes)
ereport(LOG,
(errmsg("PCP process with pid: %d exit with SUCCESS.", pid)));
}
@@ -369,13 +370,14 @@ reaper(void)
if (WTERMSIG(status) == SIGSEGV)
ereport(WARNING,
(errmsg("PCP process with pid: %d was terminated by segmentation fault", pid)));
- else
+ else if (pool_config->log_pcp_processes)
ereport(LOG,
(errmsg("PCP process with pid: %d exits with status %d by signal %d", pid, status, WTERMSIG(status))));
}
- else
+ else if (pool_config->log_pcp_processes || status != 0)
ereport(LOG,
(errmsg("PCP process with pid: %d exits with status %d", pid, status)));
+
ereport(DEBUG2,
(errmsg("going to remove pid: %d from pid list having %d elements", pid, list_length(pcp_worker_children))));
/* remove the pid of process from the list */
diff --git a/src/sample/pgpool.conf.sample-stream b/src/sample/pgpool.conf.sample-stream
index 666c16e6f..072ee7d5e 100644
--- a/src/sample/pgpool.conf.sample-stream
+++ b/src/sample/pgpool.conf.sample-stream
@@ -248,6 +248,8 @@ backend_clustering_mode = 'streaming_replication'
# Log connections
#log_disconnections = off
# Log disconnections
+#log_pcp_processes = on
+ # Log PCP Processes
#log_hostname = off
# Hostname will be shown in ps status
# and in logs if connections are logged
diff --git a/src/utils/pool_process_reporting.c b/src/utils/pool_process_reporting.c
index 924f455ac..e758c45a5 100644
--- a/src/utils/pool_process_reporting.c
+++ b/src/utils/pool_process_reporting.c
@@ -441,6 +441,11 @@ get_config(int *nrows)
StrNCpy(status[i].desc, "if true, print closing connections to the log", POOLCONFIG_MAXDESCLEN);
i++;
+ StrNCpy(status[i].name, "log_pcp_processes", POOLCONFIG_MAXNAMELEN);
+ snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->log_pcp_processes);
+ StrNCpy(status[i].desc, "if true, print PCP process forks and anormal exit status to the log", POOLCONFIG_MAXDESCLEN);
+ i++;
+
StrNCpy(status[i].name, "log_hostname", POOLCONFIG_MAXNAMELEN);
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->log_hostname);
StrNCpy(status[i].desc, "if true, resolve hostname for ps and log print", POOLCONFIG_MAXDESCLEN);
[parent: 2ec15ef66561]