pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: Patrick Stählin <me@packi.ch>
Cc: pgsql-bugs@lists.postgresql.org, Heikki Linnakangas <heikki.linnakangas@iki.fi>
Subject: Re: BUG #18996: Assertion fails in waiteventset.c when dropping database in single mode in PG18
Date: Fri, 25 Jul 2025 10:01:11 +0900
Message-ID: <aILXVzYNhVm-yl7o@paquier.xyz> (raw)
In-Reply-To: <32f9406b-d3c7-4dd4-9027-d72c116d199d@packi.ch>
References: <18996-3a2744c8140488de@postgresql.org>
	<32f9406b-d3c7-4dd4-9027-d72c116d199d@packi.ch>

On Thu, Jul 24, 2025 at 03:46:12PM +0200, Patrick Stählin wrote:
> We, or rather git bisect, traced it down to commit
> 84e5b2f07a5e8ba983ff0f6e71b063b27f45f346 that added a new wait event in
> InitializeLatchWaitSet if we're running under postmaster but then didn't add
> the same check in WaitLatch and always referenced it. This probably caused
> the assert later on, when we were waiting on the ProcBarrier.
> 
> I've attached a patch based on REL_18_STABLE that seems to fix the issue for
> us and passes the selftests.

That's the same kind of single-user-mode shortcut we have in the past
for similar issues, like 0ce5cf2ef24f for example.

@@ -187,9 +187,10 @@ WaitLatch(Latch *latch, int wakeEvents, long timeout,
     if (!(wakeEvents & WL_LATCH_SET))
         latch = NULL;
     ModifyWaitEvent(LatchWaitSet, LatchWaitSetLatchPos, WL_LATCH_SET, latch);
-    ModifyWaitEvent(LatchWaitSet, LatchWaitSetPostmasterDeathPos,
-                    (wakeEvents & (WL_EXIT_ON_PM_DEATH | WL_POSTMASTER_DEATH)),
-                    NULL);
+    if (IsUnderPostmaster)
+        ModifyWaitEvent(LatchWaitSet, LatchWaitSetPostmasterDeathPos,
+                        (wakeEvents & (WL_EXIT_ON_PM_DEATH | WL_POSTMASTER_DEATH)),
+                        NULL);

Yeah, that looks good to me.  It does not make sense to rely on that
for !IsUnderPostmaster, which is something that we obviously support
in WaitLatch() based on the assertion a couple of lines above while
the initialization happens.  Will fix, thanks for the report!
--
Michael

Attachments:

  [application/pgp-signature] signature.asc (832B, ../aILXVzYNhVm-yl7o@paquier.xyz/2-signature.asc)
  download

view thread (3+ messages)

Message-ID: <aILXVzYNhVm-yl7o@paquier.xyz>
Permalink:  ../aILXVzYNhVm-yl7o@paquier.xyz/
Also on:    postgresql.org/message-id/aILXVzYNhVm-yl7o@paquier.xyz

 · 

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-bugs@postgresql.org
  Cc: michael@paquier.xyz, me@packi.ch, heikki.linnakangas@iki.fi
  Subject: Re: BUG #18996: Assertion fails in waiteventset.c when dropping database in single mode in PG18
  In-Reply-To: <aILXVzYNhVm-yl7o@paquier.xyz>

* 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