Re: GetNamedLWLockTranche crashes on Windows in normal backend

2025-09-04 Thread Nathan Bossart
On Thu, Sep 04, 2025 at 04:12:09PM -0500, Sami Imseih wrote: >> Yeah, I think modeling this after commit 4f2400c is a reasonable thing to >> explore. > > Here it is as described above. Thanks. This looks like the right idea to me, but let's give some time for others to comment. -- nathan

Re: GetNamedLWLockTranche crashes on Windows in normal backend

2025-09-04 Thread Sami Imseih
> Yeah, I think modeling this after commit 4f2400c is a reasonable thing to > explore. Here it is as described above. -- Sami v2-0001-Prevent-crash-when-retreiving-LWLock-tranches.patch Description: Binary data

Re: GetNamedLWLockTranche crashes on Windows in normal backend

2025-09-04 Thread Nathan Bossart
On Thu, Sep 04, 2025 at 01:23:26PM -0500, Sami Imseih wrote: > I suggest we set an in progres flag for shmem_startup_hook, as we do for > shmem_request_hook, and error out this function if called outside of this > hook. The error will be something like this: > > ``` > ERROR: cannot return the add

Re: GetNamedLWLockTranche crashes on Windows in normal backend

2025-09-04 Thread Sami Imseih
commit 38b602b certainly doesn't do us any favors here since it > removed NamedLWLockTrancheArray. Given the lack of reports from the field, > I suspect the best path forward is to add an ERROR for unsafe accesses and > to fix the documentation, as discussed upthread. I suggest we set an in progr

Re: GetNamedLWLockTranche crashes on Windows in normal backend

2025-09-03 Thread Nathan Bossart
Well, commit 38b602b certainly doesn't do us any favors here since it removed NamedLWLockTrancheArray. Given the lack of reports from the field, I suspect the best path forward is to add an ERROR for unsafe accesses and to fix the documentation, as discussed upthread. -- nathan

Re: GetNamedLWLockTranche crashes on Windows in normal backend

2025-08-25 Thread Nathan Bossart
On Mon, Aug 25, 2025 at 04:28:09PM -0500, Sami Imseih wrote: > Here it is. Looks reasonable to me. I'll leave this one around for a week or two to give others a chance to comment. -- nathan

Re: GetNamedLWLockTranche crashes on Windows in normal backend

2025-08-25 Thread Sami Imseih
Here it is. I was hoping we can even get rid of NamedLWLockTrancheRequests altogether, but that's not going to be possible because RequestNamedLWLockTranche happens earlier than CreateLWLocks, so NamedLWLockTrancheRequests is essentially tracking the requested lwlocks until we get a chance to crea

Re: GetNamedLWLockTranche crashes on Windows in normal backend

2025-08-25 Thread Sami Imseih
> > Another approach is to just change GetNamedLWLockTranche to use > > NamedLWLockTrancheArray since that is already copied in EXEC_BACKEND, and > > allow GetNamedLWLockTranche to continue to be used outside of startup. In > > this case, we will need to add num_lwlocks field to > > NamedLWLockTran

Re: GetNamedLWLockTranche crashes on Windows in normal backend

2025-08-25 Thread Nathan Bossart
On Mon, Aug 25, 2025 at 01:44:22PM -0500, Sami Imseih wrote: > Another approach is to just change GetNamedLWLockTranche to use > NamedLWLockTrancheArray since that is already copied in EXEC_BACKEND, and > allow GetNamedLWLockTranche to continue to be used outside of startup. In > this case, we will

Re: GetNamedLWLockTranche crashes on Windows in normal backend

2025-08-25 Thread Sami Imseih
> Attached is a repro patch. You will need to set > shared_preload_libraries = 'pg_stat_statements' > as well. I forgot to mention. Once patched, you can run a simple select statement from a new connection to force the crash. This is because GetNamedLWLockTranche will be called at pgss_ExecutorEnd

Re: GetNamedLWLockTranche crashes on Windows in normal backend

2025-08-25 Thread Sami Imseih
> 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, > > s

Re: GetNamedLWLockTranche crashes on Windows in normal backend

2025-08-25 Thread Nathan Bossart
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 n

Re: GetNamedLWLockTranche crashes on Windows in normal backend

2025-08-25 Thread Sami Imseih
> On Fri, Aug 22, 2025 at 02:21:55PM -0500, Sami Imseih wrote: > > While working on [0], I observed that $SUBJECT. I encountered this issue > > while building test cases for [0], and in which GetNamedLWLockTranche is > > called outside of startup. > > > > [...] > > > > I repro'd this on a Windows m

Re: GetNamedLWLockTranche crashes on Windows in normal backend

2025-08-25 Thread Nathan Bossart
On Fri, Aug 22, 2025 at 02:21:55PM -0500, Sami Imseih wrote: > While working on [0], I observed that $SUBJECT. I encountered this issue > while building test cases for [0], and in which GetNamedLWLockTranche is > called outside of startup. > > [...] > > I repro'd this on a Windows machine, but on

GetNamedLWLockTranche crashes on Windows in normal backend

2025-08-22 Thread Sami Imseih
Hi, While working on [0], I observed that $SUBJECT. I encountered this issue while building test cases for [0], and in which GetNamedLWLockTranche is called outside of startup. This crash, reproducible on HEAD, occurs because NamedLWLockTrancheRequestArray ( a local array populated during shmem_r