From: Tatsuo Ishii Date: Sat, 15 Apr 2023 02:59:43 +0000 (+0900) Subject: Add new config parameter "log_pcp_processes", X-Git-Tag: V4_5_0_BETA1~81 X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=84d66997dedb9f2e203da4f094fbecdec2ec16ba;p=pgpool2.git 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 --- 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 + + log_pcp_processes (boolean) + + + log_pcp_processes 設定パラメータ + + + + + + onに設定されている場合、PCPプロセスの正常なforkあるいはexitした状態をログに出力します。 + デフォルトはonです。 + + + + このパラメータはPgpool-IIの設定を再読み込みすることで変更可能です。 + + + + log_error_verbosity (enum) 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 @@ + + log_pcp_processes (boolean) + + log_pcp_processes configuration parameter + + + + + Setting to on, enable logging about normal PCP Process + fork and exit statues. Default is on. + + + This parameter can be changed by reloading the Pgpool-II configurations. + + + + log_error_verbosity (enum) 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);