Add new config parameter "log_pcp_processes",
authorTatsuo Ishii <ishii@sraoss.co.jp>
Sat, 15 Apr 2023 02:59:43 +0000 (11:59 +0900)
committerTatsuo Ishii <ishii@sraoss.co.jp>
Sat, 15 Apr 2023 02:59:43 +0000 (11:59 +0900)
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
doc/src/sgml/connection-pooling.sgml
src/config/pool_config_variables.c
src/include/pool_config.h
src/pcp_con/pcp_child.c
src/sample/pgpool.conf.sample-stream
src/utils/pool_process_reporting.c

index 64e2fb98b9d14aa9198c8fd98d206ebbc73347e2..d7bec36bb7e17e32fb97ae9ea6e6ed2b7e0fb3ca 100644 (file)
@@ -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>
index 9b376329e722f456ff7e9d06b9f25f97a1e4e9ac..28dcb4a36c39e41ec2b4053f80f7c2822c6cc3d5 100644 (file)
     </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>
index 38de1d05a515647cef2d15fc14e5317b77e2999c..9fb53c17ebb7857fb6e54102ce0ee7d4cb9891ae 100644 (file)
@@ -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.",
index 4a9b2133ddba3838c10fd61586aedf486f6bb687..50ffb33892695e94c70aa2280638f40fcee496ee 100644 (file)
@@ -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 */
index 1b81f703019f1a1fd0d0938fa748167387b8050c..6c3f870925c0d126715af4a13ac79b8e20a30ac7 100644 (file)
@@ -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 */
index 666c16e6fcffbbdf087bd313f91bbf5061bebd5a..072ee7d5e4780f9c23bfc507dc8e2571303b0233 100644 (file)
@@ -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
index 924f455acf35c08af24387e18ebdd096025b246d..e758c45a543c9de6c20ca3ee05fe66f5b7cbdeb3 100644 (file)
@@ -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);