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