Thread

Commits

  1. Fix use of proc number in pgstat_create_backend()

  1. Concerns regarding code in pgstat_backend.c

    Ryo Matsumura (Fujitsu) <matsumura.ryo@fujitsu.com> — 2026-02-06T07:11:07Z

    Hi, Michael and Hackers,
    
    I found the code that is likely to cause bugs in the future. It's not currently a bug.
    Should I have misunderstood, please feel free to disregard this email.
    
    pgstat_create_backend(ProcNumber procnum) uses MyProcNumber instead of the argument.
    I've had a quick look through the commit log and thread, but I don't seem to have found the reason.
    Wouldn't it be better to use 'procnum'?
    
    This change seems to have appeared in v2-0002-More-work-to-allow-backend-statistics-in-critical.patch on 2025-01-20 06:34:41
    https://www.postgresql.org/message-id/flat/66efowskppsns35v5u2m7k4sdnl7yoz5bo64tdjwq7r5lhplrz%40y7dme5xwh2r5#fba8e490848df1798e7c693c70a43f56
    
    Best Regards
    Ryo Matsumura
    
  2. Re: Concerns regarding code in pgstat_backend.c

    Michael Paquier <michael@paquier.xyz> — 2026-02-06T07:34:44Z

    On Fri, Feb 06, 2026 at 07:11:07AM +0000, Ryo Matsumura (Fujitsu) wrote:
    > I found the code that is likely to cause bugs in the future. It's not currently a bug.
    > Should I have misunderstood, please feel free to disregard this email.
    
    Because this is a clear thinko.  pgstat_bestart_final() is always a
    code path taken after pgstat_beinit() for auxiliary processes and the
    rest of the world.  I am pretty sure that my intention here was to
    use the argument and not MyProcNumber in the function
    pgstat_create_backend() because we rely on MyProcNumber to be defined
    when the create routine is called, and that's what
    pgstat_bestart_final() offers as guarantee, due to pgstat_beinit().
    
    There is no bug currently, but let's clean that up in all the branches
    anyway for clarity and any future back-patch.  Hence, what do you think
    about the attached? 
    --
    Michael
    
  3. RE: Concerns regarding code in pgstat_backend.c

    Ryo Matsumura (Fujitsu) <matsumura.ryo@fujitsu.com> — 2026-02-06T09:02:46Z

    On Fri, Mar 06, 2026 at 07:34 AM UTC, Michael Paquier wrote:
    > > There is no bug currently, but let's clean that up in all the branches
    > > anyway for clarity and any future back-patch.  Hence, what do you think
    > > about the attached?
    
    I think attached code causes no concern.
    
    Best Regards
    Ryo Matsumura
    
    
    
    
  4. Re: Concerns regarding code in pgstat_backend.c

    Michael Paquier <michael@paquier.xyz> — 2026-02-06T10:59:51Z

    On Fri, Feb 06, 2026 at 09:02:46AM +0000, Ryo Matsumura (Fujitsu) wrote:
    > I think attached code causes no concern.
    
    Fixed that while I had my mind on it.  Thanks for the report.
    --
    Michael