[pgpool-hackers: 3694] Re: [pgpool-committers: 6810] pgpool: Adding log collector

Muhammad Usama m.usama at gmail.com
Fri Jul 3 03:22:28 JST 2020


On Thu, Jul 2, 2020 at 7:19 PM Tatsuo Ishii <ishii at sraoss.co.jp> wrote:

> Hi Usama,
>
> Thank you for the prompt reply.
>
> > Hi Ishii-San
> >
> > Sorry, it was a mistake on my part. Actually I added a new global
> variable
> > myProcPid to hold to the process PID so that we can avoid calling
> getpid()
> > function
> > every time during constructing the log string.
> > This change was meant to increase the performance but unfortunately
> > I missed setting the myProcPid variable after fork() at one of the
> places.
> > ( After forking the pgpool child process).
> >
> >
> > While fixing the issue I did a little bit of refactoring and  created a
> new
> > function that sets all process-related global variables
> > (application_name, myProcPid and application type) so that we can avoid
> > such type of mistakes.
> >
> > Also, I have made a few changes in functions for setting the
> > application_name and moved them to
> > pool_globasl.c from pgpool_main.c
> >
> > Can you have a look at the attached patch to see if it fixes the problem?
> > and if you are okay
> > with the reorganization/changes in application_name related functions.
>
> The fix and refactoring looks good to me.  Yes, I agree that current
> code could easily produce human mistakes and I like your idea to
> refactor them.
>

Thanks for the confirmation. I have pushed the patch .

Best Regards
Muhammad Usama


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


More information about the pgpool-hackers mailing list