From: Patrick Stählin <me@packi.ch>
To: pgsql-bugs@lists.postgresql.org
Cc: Heikki Linnakangas <heikki.linnakangas@iki.fi>
Subject: Re: BUG #18996: Assertion fails in waiteventset.c when dropping database in single mode in PG18
Date: Thu, 24 Jul 2025 15:46:12 +0200
Message-ID: <32f9406b-d3c7-4dd4-9027-d72c116d199d@packi.ch> (raw)
In-Reply-To: <18996-3a2744c8140488de@postgresql.org>
References: <18996-3a2744c8140488de@postgresql.org>
Hi!
On 7/24/25 11:49 AM, PG Bug reporting form wrote:
>
> We're starting to incorporate PG18 (REL_18_BETA2) in our builds/testing. Our
> tests currently fail because we drop the postgres database in single mode
> before we give our customers access to them, as they won't have superuser
> access and we allow them to re-create that database. It also triggers when I
> create a database foo and then drop it so it's not related to the postgres
> database specifically. The assert doesn't trigger with REL_17_5 built with
> the same instructions.
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.
Thanks,
Patrick
Attachments:
[text/x-patch] 0001-Do-not-modify-wait-events-we-never-added.patch (1.5K, ../32f9406b-d3c7-4dd4-9027-d72c116d199d@packi.ch/2-0001-Do-not-modify-wait-events-we-never-added.patch)
download | inline diff:
From f31e5efb33a82cd2fc646f9717d46682ec4c5471 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Patrick=20St=C3=A4hlin?= <me@packi.ch>
Date: Thu, 24 Jul 2025 15:16:00 +0200
Subject: [PATCH] Do not modify wait events we never added
Commit 84e5b2f07a5e8ba983ff0f6e71b063b27f45f346 added a new wait event
if we're running under postmaster but it seems like we always reference
LatchWaitSetPostmasterDeathPos in WaitLatch even if we didn't add the
WaitEvent.
This caused postgres in --single mode to crash when waiting in
WaitForProcSignalBarrier after dropping a database.
Co-authored-by: Ronan Dunklau <ronan.dunklau@aiven.io>
---
src/backend/storage/ipc/latch.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/backend/storage/ipc/latch.c b/src/backend/storage/ipc/latch.cindex c6aefd2f688..f4e17ab526b 100644--- a/src/backend/storage/ipc/latch.c+++ b/src/backend/storage/ipc/latch.c@@ -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);
if (WaitEventSetWait(LatchWaitSet,
(wakeEvents & WL_TIMEOUT) ? timeout : -1,
--
2.48.1
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: me@packi.ch, pgsql-bugs@lists.postgresql.org, heikki.linnakangas@iki.fi
Subject: Re: BUG #18996: Assertion fails in waiteventset.c when dropping database in single mode in PG18
In-Reply-To: <32f9406b-d3c7-4dd4-9027-d72c116d199d@packi.ch>
* 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