pgsql: Allow unknown-size shmem attachments in single-user mode

From: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Allow unknown-size shmem attachments in single-user mode
Date: 2026-09-30 11:43:12
Message-ID: E1xBsiO-00000001rda-2Sty@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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(dot)slg01(at)gmail(dot)com>
Reviewed-by: Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>
Discusssion: https://www.postgresql.org/message-id/CAJTYsWXREGXCnWdZJsXt8pT2UY_Y2GSx+HOUu2X3s8YDCLj0_A@mail.gmail.com
Backpatch-through: 19

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/67c01b84788d1d58312d7d1691f160f681ec5984

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(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Heikki Linnakangas 2026-09-30 12:41:15 pgsql: Fix autovacuum docs related to widening multixid offsets to 64 b
Previous Message Michael Paquier 2026-09-30 05:38:04 pgsql: Fix clobbering of proc entry's statusFlags during slot invalidat