From: Heikki Linnakangas <heikki.linnakangas@iki.fi>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Allow unknown-size shmem attachments in single-user mode
Date: Wed, 30 Sep 2026 11:43:12 +0000
Message-ID: <E1xBsiO-00000001rdY-2OE8@gemulon.postgresql.org> (raw)
Allow unknown-size shmem attachments in single-user mode
ShmemRequestInternal() rejected SHMEM_ATTACH_UNKNOWN_SIZE whenever
IsUnderPostmaster was false. That also rejected an after-startup
attachment in a standalone backend, even if the area exists.
To fix, check whether the shared memory has been initialized
(ShmemIndex == NULL) rather than IsUnderPostmaster.
Refactor the tests, and add more test cases for after-startup
attachment, with SHMEM_ATTACH_UNKNOWN_SIZE and a mismatching size, and
for this single-user case.
Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Discusssion: https://www.postgresql.org/message-id/CAJTYsWXREGXCnWdZJsXt8pT2UY_Y2GSx+HOUu2X3s8YDCLj0_A@mail.gmail...
Backpatch-through: 19
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/c712b0d49b971fe7cf521c057bc7adb63b17760c
Modified Files
--------------
src/backend/storage/ipc/shmem.c | 26 ++-
.../modules/test_shmem/t/001_late_shmem_alloc.pl | 182 ++++++++++++++-------
src/test/modules/test_shmem/test_shmem--1.0.sql | 4 +
src/test/modules/test_shmem/test_shmem.c | 55 +++++++
4 files changed, 190 insertions(+), 77 deletions(-)
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: heikki.linnakangas@iki.fi
Subject: Re: pgsql: Allow unknown-size shmem attachments in single-user mode
In-Reply-To: <E1xBsiO-00000001rdY-2OE8@gemulon.postgresql.org>
References: <E1xBsiO-00000001rdY-2OE8@gemulon.postgresql.org>
* 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