<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jul 2, 2020 at 7:19 PM Tatsuo Ishii &lt;<a href="mailto:ishii@sraoss.co.jp">ishii@sraoss.co.jp</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Usama,<br>
<br>
Thank you for the prompt reply.<br>
<br>
&gt; Hi Ishii-San<br>
&gt; <br>
&gt; Sorry, it was a mistake on my part. Actually I added a new global variable<br>
&gt; myProcPid to hold to the process PID so that we can avoid calling getpid()<br>
&gt; function<br>
&gt; every time during constructing the log string.<br>
&gt; This change was meant to increase the performance but unfortunately<br>
&gt; I missed setting the myProcPid variable after fork() at one of the places.<br>
&gt; ( After forking the pgpool child process).<br>
&gt; <br>
&gt; <br>
&gt; While fixing the issue I did a little bit of refactoring and  created a new<br>
&gt; function that sets all process-related global variables<br>
&gt; (application_name, myProcPid and application type) so that we can avoid<br>
&gt; such type of mistakes.<br>
&gt; <br>
&gt; Also, I have made a few changes in functions for setting the<br>
&gt; application_name and moved them to<br>
&gt; pool_globasl.c from pgpool_main.c<br>
&gt; <br>
&gt; Can you have a look at the attached patch to see if it fixes the problem?<br>
&gt; and if you are okay<br>
&gt; with the reorganization/changes in application_name related functions.<br>
<br>
The fix and refactoring looks good to me.  Yes, I agree that current<br>
code could easily produce human mistakes and I like your idea to<br>
refactor them.<br></blockquote><div><br></div><div>Thanks for the confirmation. I have pushed the patch .</div><div><br></div><div>Best Regards</div><div>Muhammad Usama</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
&gt; Thanks<br>
&gt; Best Regards<br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; On Wed, Jul 1, 2020 at 4:39 AM Tatsuo Ishii &lt;<a href="mailto:ishii@sraoss.co.jp" target="_blank">ishii@sraoss.co.jp</a>&gt; wrote:<br>
&gt; <br>
&gt;&gt; Hi Usama,<br>
&gt;&gt;<br>
&gt;&gt; It seems the behavior change of &quot;%p&quot; was intentional.<br>
&gt;&gt; Can you tell me what&#39;s the reasoning behind this?<br>
&gt;&gt;<br>
&gt; <br>
&gt; This change was done to avoid calling the system call getpid() every time.<br>
&gt; Though the below<br>
&gt; mentioned change was intentional but was not meant to disturb or change the<br>
&gt; behavior of %p<br>
&gt; <br>
&gt;&gt;<br>
&gt;&gt; @@ -1944,7 +1996,6 @@ log_line_prefix(StringInfo buf, const char<br>
&gt;&gt; *line_prefix, ErrorData *edata)<br>
&gt;&gt;         static int      log_my_pid = 0;<br>
&gt;&gt;         int                     padding;<br>
&gt;&gt;         const char *p;<br>
&gt;&gt; -       int                     MyProcPid = getpid();<br>
&gt;&gt;<br>
&gt;&gt;         POOL_CONNECTION *frontend = NULL;<br>
&gt;&gt;         POOL_SESSION_CONTEXT *session = pool_get_session_context(true);<br>
&gt;&gt; @@ -1958,10 +2009,10 @@ log_line_prefix(StringInfo buf, const char<br>
&gt;&gt; *line_prefix, ErrorData *edata)<br>
&gt;&gt;          * MyProcPid changes. MyStartTime also changes when MyProcPid<br>
&gt;&gt; does, so<br>
&gt;&gt;          * reset the formatted start timestamp too.<br>
&gt;&gt;          */<br>
&gt;&gt; -       if (log_my_pid != MyProcPid)<br>
&gt;&gt; +       if (log_my_pid != myProcPid)<br>
&gt;&gt;         {<br>
&gt;&gt;                 log_line_number = 0;<br>
&gt;&gt; -               log_my_pid = MyProcPid;<br>
&gt;&gt; +               log_my_pid = myProcPid;<br>
&gt;&gt;         }<br>
&gt;&gt;<br>
&gt;&gt; From: Tatsuo Ishii &lt;<a href="mailto:ishii@sraoss.co.jp" target="_blank">ishii@sraoss.co.jp</a>&gt;<br>
&gt;&gt; Subject: [pgpool-hackers: 3685] Re: [pgpool-committers: 6810] pgpool:<br>
&gt;&gt; Adding log collector<br>
&gt;&gt; Date: Tue, 30 Jun 2020 21:56:47 +0900 (JST)<br>
&gt;&gt; Message-ID: &lt;<a href="mailto:20200630.215647.616406990083764189.t-ishii@sraoss.co.jp" target="_blank">20200630.215647.616406990083764189.t-ishii@sraoss.co.jp</a>&gt;<br>
&gt;&gt;<br>
&gt;&gt; &gt; Hi Usama,<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; After this commit, pid (%p) in pgpool log becomes all same as the<br>
&gt;&gt; &gt; pgpool main process except PCP process (logging_collector = off). Can<br>
&gt;&gt; &gt; you please look into this? This is inconvenient for testing and<br>
&gt;&gt; &gt; debugging Pgpool-II.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; 2020-06-30 21:51:48: pid 30695: LOG:  Backend status file<br>
&gt;&gt; /home/t-ishii/work/Pgpool-II/current/c/log/pgpool_status discarded<br>
&gt;&gt; &gt; 2020-06-30 21:51:48: pid 30695: LOG:  memory cache initialized<br>
&gt;&gt; &gt; 2020-06-30 21:51:48: pid 30695: DETAIL:  memcache blocks :64<br>
&gt;&gt; &gt; 2020-06-30 21:51:48: pid 30695: LOG:  pool_discard_oid_maps: discarded<br>
&gt;&gt; memqcache oid maps<br>
&gt;&gt; &gt; 2020-06-30 21:51:48: pid 30695: LOG:<br>
&gt;&gt; health_check_stats_shared_memory_size: requested size: 12288<br>
&gt;&gt; &gt; 2020-06-30 21:51:48: pid 30695: LOG:<br>
&gt;&gt; health_check_stats_shared_memory_size: requested size: 12288<br>
&gt;&gt; &gt; 2020-06-30 21:51:48: pid 30695: LOG:  Setting up socket for<br>
&gt;&gt; <a href="http://127.0.0.1:11000" rel="noreferrer" target="_blank">127.0.0.1:11000</a><br>
&gt;&gt; &gt; 2020-06-30 21:51:48: pid 30695: LOG:  find_primary_node_repeatedly:<br>
&gt;&gt; waiting for finding a primary node<br>
&gt;&gt; &gt; 2020-06-30 21:51:48: pid 30695: LOG:  find_primary_node: primary node is<br>
&gt;&gt; 0<br>
&gt;&gt; &gt; 2020-06-30 21:51:48: pid 30695: LOG:  find_primary_node: standby node is<br>
&gt;&gt; 1<br>
&gt;&gt; &gt; 2020-06-30 21:51:48: pid 30733: LOG:  PCP process: 30733 started<br>
&gt;&gt; &gt; 2020-06-30 21:51:48: pid 30695: LOG:  pgpool-II successfully started.<br>
&gt;&gt; version 4.2devel (chichiriboshi)<br>
&gt;&gt; &gt; 2020-06-30 21:51:48: pid 30695: LOG:  node status[0]: 1<br>
&gt;&gt; &gt; 2020-06-30 21:51:48: pid 30695: LOG:  node status[1]: 2<br>
&gt;&gt; &gt; 2020-06-30 21:51:56: pid 30695: LOG:  DB node id: 0 backend pid: 30744<br>
&gt;&gt; statement: SELECT version()<br>
&gt;&gt; &gt; 2020-06-30 21:51:56: pid 30695: LOG:  pool_reuse_block: blockid: 0<br>
&gt;&gt; &gt; 2020-06-30 21:51:56: pid 30695: CONTEXT:  while searching system<br>
&gt;&gt; catalog, When relcache is missed<br>
&gt;&gt; &gt; 2020-06-30 21:51:56: pid 30695: LOG:  DB node id: 0 backend pid: 30744<br>
&gt;&gt; statement: select 1<br>
&gt;&gt; &gt; 2020-06-30 21:51:56: pid 30695: LOG:  DB node id: 0 backend pid: 30744<br>
&gt;&gt; statement:  DISCARD ALL<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; From: Muhammad Usama &lt;<a href="mailto:m.usama@gmail.com" target="_blank">m.usama@gmail.com</a>&gt;<br>
&gt;&gt; &gt; Subject: [pgpool-committers: 6810] pgpool: Adding log collector<br>
&gt;&gt; &gt; Date: Fri, 26 Jun 2020 19:32:40 +0000<br>
&gt;&gt; &gt; Message-ID: &lt;<a href="mailto:E1jou5Y-0001kP-P4@gothos.postgresql.org" target="_blank">E1jou5Y-0001kP-P4@gothos.postgresql.org</a>&gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; Adding log collector<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; Molding the syslogger of PostgreSQL to work with<br>
&gt;&gt; &gt;&gt; Pgpool-II so that we can have log rotation<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; Documentation updates will follow soon.<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; Branch<br>
&gt;&gt; &gt;&gt; ------<br>
&gt;&gt; &gt;&gt; master<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; Details<br>
&gt;&gt; &gt;&gt; -------<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; <a href="https://git.postgresql.org/gitweb?p=pgpool2.git;a=commitdiff;h=35037bcd837472f04b92008362db7f3cefa88bec" rel="noreferrer" target="_blank">https://git.postgresql.org/gitweb?p=pgpool2.git;a=commitdiff;h=35037bcd837472f04b92008362db7f3cefa88bec</a><br>
&gt;&gt; &gt;&gt; Author: Muhammad Usama &lt;m.usama@HighGo.ca&gt;<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; Modified Files<br>
&gt;&gt; &gt;&gt; --------------<br>
&gt;&gt; &gt;&gt; configure                                          |   85 ++<br>
&gt;&gt; &gt;&gt; src/Makefile.am                                    |    1 +<br>
&gt;&gt; &gt;&gt; src/Makefile.in                                    |   30 +-<br>
&gt;&gt; &gt;&gt; src/config/pool_config_variables.c                 |   68 ++<br>
&gt;&gt; &gt;&gt; src/include/main/pgpool_logger.h                   |   96 ++<br>
&gt;&gt; &gt;&gt; src/include/pool.h                                 |    2 +<br>
&gt;&gt; &gt;&gt; src/include/pool_config.h                          |    9 +<br>
&gt;&gt; &gt;&gt; src/include/utils/timestamp.h                      |  214 ++++<br>
&gt;&gt; &gt;&gt; src/libs/pcp/Makefile.in                           |    2 +-<br>
&gt;&gt; &gt;&gt; src/main/main.c                                    |    2 +<br>
&gt;&gt; &gt;&gt; src/main/pgpool_logger.c                           | 1176<br>
&gt;&gt; ++++++++++++++++++++<br>
&gt;&gt; &gt;&gt; src/main/pgpool_main.c                             |  216 ++--<br>
&gt;&gt; &gt;&gt; src/main/pool_globals.c                            |    1 +<br>
&gt;&gt; &gt;&gt; src/pcp_con/pcp_child.c                            |    1 +<br>
&gt;&gt; &gt;&gt; src/sample/pgpool.conf.sample-logical              |   34 +-<br>
&gt;&gt; &gt;&gt; src/sample/pgpool.conf.sample-raw                  |   42 +-<br>
&gt;&gt; &gt;&gt; src/sample/pgpool.conf.sample-replication          |   34 +-<br>
&gt;&gt; &gt;&gt; src/sample/pgpool.conf.sample-slony                |   44 +-<br>
&gt;&gt; &gt;&gt; src/sample/pgpool.conf.sample-snapshot             |   44 +-<br>
&gt;&gt; &gt;&gt; src/sample/pgpool.conf.sample-stream               |   33 +-<br>
&gt;&gt; &gt;&gt; .../tests/010.rewrite_timestamp/timestamp/Makefile |    2 +<br>
&gt;&gt; &gt;&gt; .../tests/010.rewrite_timestamp/timestamp/main.c   |    2 +-<br>
&gt;&gt; &gt;&gt; src/tools/pcp/Makefile.in                          |   18 +-<br>
&gt;&gt; &gt;&gt; src/utils/error/elog.c                             |   74 +-<br>
&gt;&gt; &gt;&gt; src/watchdog/watchdog.c                            |    1 +<br>
&gt;&gt; &gt;&gt; src/watchdog/wd_escalation.c                       |    2 +<br>
&gt;&gt; &gt;&gt; src/watchdog/wd_heartbeat.c                        |    2 +<br>
&gt;&gt; &gt;&gt; src/watchdog/wd_if.c                               |    1 +<br>
&gt;&gt; &gt;&gt; src/watchdog/wd_lifecheck.c                        |    1 +<br>
&gt;&gt; &gt;&gt; src/watchdog/wd_ping.c                             |    1 +<br>
&gt;&gt; &gt;&gt; 30 files changed, 2092 insertions(+), 146 deletions(-)<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt; _______________________________________________<br>
&gt;&gt; &gt; pgpool-hackers mailing list<br>
&gt;&gt; &gt; <a href="mailto:pgpool-hackers@pgpool.net" target="_blank">pgpool-hackers@pgpool.net</a><br>
&gt;&gt; &gt; <a href="http://www.pgpool.net/mailman/listinfo/pgpool-hackers" rel="noreferrer" target="_blank">http://www.pgpool.net/mailman/listinfo/pgpool-hackers</a><br>
&gt;&gt;<br>
&gt; <br>
&gt; <br>
&gt; -- <br>
&gt; ...<br>
&gt; Muhammad Usama<br>
&gt; Highgo Software (Canada/China/Pakistan)<br>
&gt; URL : <a href="http://www.highgo.ca" rel="noreferrer" target="_blank">http://www.highgo.ca</a><br>
&gt; ADDR: 10318 WHALLEY BLVD, Surrey, BC<br>
</blockquote></div></div>