pgsql: Fix DSA allocation to honor DSA_ALLOC_NO_OOM when out of DSM seg

From: Masahiko Sawada <msawada(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix DSA allocation to honor DSA_ALLOC_NO_OOM when out of DSM seg
Date: 2026-11-18 18:59:08
Message-ID: E1xTks7-00000000HcQ-07mz@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix DSA allocation to honor DSA_ALLOC_NO_OOM when out of DSM segments.

Callers allocating DSA memory with DSA_ALLOC_NO_OOM expect to get
InvalidDsaPointer on allocation failure so that they can clean up and
handle the failure themselves. However, since commit 13df76a537c, a
new DSM segment for a DSA area has been created without
DSM_CREATE_NULL_IF_MAXSEGMENTS, so running out of DSM segments raised
an ERROR instead of returning InvalidDsaPointer.

Fix by passing DSM_CREATE_NULL_IF_MAXSEGMENTS.

Backpatch to all supported versions.

Author: Baji Shaik <baji(dot)pgdev(at)gmail(dot)com>
Reviewed-by: Zhijie Hou <houzhijie22(at)gmail(dot)com>
Reviewed-by: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
Reviewed-by: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Discussion: https://postgr.es/m/CA+fm-RMyb6EoMuk+a4_hZou9cdTHfB6mj1UV-7yb_YuTWLug1g@mail.gmail.com
Backpatch-through: 15

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/597d5c1fef84855254bdc93ebfa612beff889006

Modified Files
--------------
src/backend/utils/mmgr/dsa.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

Browse pgsql-committers by date

  From Date Subject
Next Message David Rowley 2026-11-18 20:08:57 pgsql: Robustify pg_column_is_updatable() against overly large attnums
Previous Message Masahiko Sawada 2026-11-18 18:59:01 pgsql: Fix DSA allocation to honor DSA_ALLOC_NO_OOM when out of DSM seg