pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Nathan Bossart <nathandbossart@gmail.com>
To: Sami Imseih <samimseih@gmail.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: Re: GetNamedLWLockTranche crashes on Windows in normal backend
Date: Mon, 25 Aug 2025 13:31:26 -0500
Message-ID: <aKyr_rVOtlolDcy-@nathan> (raw)
In-Reply-To: <CAA5RZ0u4BDp4ENjOyZ7NADz+jdQY-=PZFQNsf0jBt1Va4QzoAA@mail.gmail.com>
References: <CAA5RZ0v1_15QPg5Sqd2Qz5rh_qcsyCeHHmRDY89xVHcy2yt5BQ@mail.gmail.com>
	<aKyTa-iOdAfKynI1@nathan>
	<CAA5RZ0u4BDp4ENjOyZ7NADz+jdQY-=PZFQNsf0jBt1Va4QzoAA@mail.gmail.com>

On Mon, Aug 25, 2025 at 12:58:08PM -0500, Sami Imseih wrote:
>> If this fails, why doesn't the call in pgss_shmem_startup() also fail?  Was
>> pg_stat_statements not loaded via shared_preload_libraries?
> 
> because the array is valid in postmaster, but it's not for a normal backend,
> since it's not getting copied.
> 
> Yes, pg_stat_statements was loaded via shared_preload_libraries. Nothing
> was done out of the ordinary.
> 
>> And is the
>> failure a segfault or a "requested tranche is not registered" error?
> 
> It's a segfault.

Oh, I see what's happening.  We are never calling GetNamedLWLockTranche()
in backends because ShmemInitStruct() always sets *found.

I'd argue that calling GetNamedLWLockTranche() outside of an "if (!found)"
block in a shmem_startup_hook doesn't follow convention, but the docs have
this note:

	shmem_startup_hook provides a convenient place for the initialization
	code, but it is not strictly required that all such code be placed in
	this hook.

Like the inaccurate sentence immediately following this one [0], it was
added by commit 964152c.  IMHO we should adjust the documentation to match
reality.

[0] https://postgr.es/m/aJ9QIF3g2QQko9wq%40nathan

-- 
nathan





view thread (33+ messages)  latest in thread

Message-ID: <aKyr_rVOtlolDcy-@nathan>
Permalink:  ../aKyr_rVOtlolDcy-@nathan/
Also on:    postgresql.org/message-id/aKyr_rVOtlolDcy-@nathan

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: nathandbossart@gmail.com, samimseih@gmail.com
  Subject: Re: GetNamedLWLockTranche crashes on Windows in normal backend
  In-Reply-To: <aKyr_rVOtlolDcy-@nathan>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox