Re: [HACKERS] PATCH: Keep one postmaster monitoring pipe per process - Mailing list pgsql-hackers

From Thomas Munro
Subject Re: [HACKERS] PATCH: Keep one postmaster monitoring pipe per process
Date
Msg-id CAEepm=3BxOHw63Anwyx=pyy7Ju8cW6T0ZXNeKQS=WZp80hv_rg@mail.gmail.com
Whole thread Raw
In response to Re: [HACKERS] PATCH: Keep one postmaster monitoring pipe perprocess  (Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>)
Responses Re: [HACKERS] PATCH: Keep one postmaster monitoring pipe perprocess  (Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>)
Re: [HACKERS] PATCH: Keep one postmaster monitoring pipe per process  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Thu, Sep 6, 2018 at 9:57 PM Kyotaro HORIGUCHI
<horiguchi.kyotaro@lab.ntt.co.jp> wrote:
> In sysloger.c, cur_flags is (just set but) no longer used.

Right.  Fixed.

> ===
> In latch.c,
>
> - The parentheses around the symbols don't seem to be needed.
> |           (wakeEvents & (WL_EXIT_ON_PM_DEATH)) != 0 ||
> |           (wakeEvents & (WL_POSTMASTER_DEATH)) != 0);

Fixed.

>   And don't we need a description about this restriction in the
>   function comment?

Ok, added.

> - I think it may be better that the followings had parentheses
>   around '&' expressions.
>
> |    if (wakeEvents & WL_POSTMASTER_DEATH && IsUnderPostmaster)
> |    if (wakeEvents & WL_EXIT_ON_PM_DEATH && IsUnderPostmaster)

Fixed.  Also I was a little inconsistent about whether to use implicit
or explicit comparison with 0, and decided to go for the former.

> All the caller sites of WaitLatch, WaitLatchOrSocket and
> WaitEventSetWait are covered by this patch and all them look
> fine.

Thanks for the review!

While rebasing, I also changed WL_EXIT_ON_PM_DEATH's means of exit
from exit(1) to proc_exit(1).  In master we're quite inconsistent
about that as you can see from the lines removed by this patch, but
the comments for proc_exit() seem to insist that it is the one true
way out.  Other than an elog(DEBUG3) message, the main difference
between proc_exit() and direct exit() seems to be the PROFILE_PID_DIR
stuff that changes directory on the way out the door for gprof users.
It looks like per-pid gmon files could have been achieved by setting
environment variables[1][2], but I guess there is some value in doing
it the same way on every platform.

[1] https://sourceware.org/git/?p=glibc.git;a=blob;f=gmon/gmon.c;hb=HEAD#l354
[2] https://github.com/freebsd/freebsd/blob/master/lib/libc/gmon/gmon.c#L154

-- 
Thomas Munro
http://www.enterprisedb.com

Attachment

pgsql-hackers by date:

Previous
From: Kyotaro HORIGUCHI
Date:
Subject: Re: Speeding up text_position_next with multibyte encodings
Next
From: Thomas Munro
Date:
Subject: Re: Synchronous replay take III