Prevent an error on attaching/creating a DSM/DSA from an interrupt handler.

From: Rahila Syed <rahilasyed90(at)gmail(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Cc: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>, Tomas Vondra <tomas(at)vondra(dot)me>
Subject: Prevent an error on attaching/creating a DSM/DSA from an interrupt handler.
Date: 2025-01-14 07:45:59
Message-ID: CAH2L28shr0j3JE5V3CXDFmDH-agTSnh2V8pR23X0UhRMbDQD9Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

If a DSM is created or attached from an interrupt handler while a
transaction is being
rolled back, it may result in the following error.
"ResourceOwnerEnlarge called after release started"
This was found during the testing of Enhancing Memory Context Reporting
feature
by Fujii Masao [1].

I propose a fix to fall back to creating a DSM or DSA with a NULL resource
owner if
CurrentResourceOwner is set to "releasing".
Since a DSM or DSA can already be created with a NULL resource owner—
meaning it persists for the lifetime of the backend or until explicitly
detached—
this approach should be acceptable.

Please find attached a patch which does that. Kindly let me know your views.

[1].
https://www.postgresql.org/message-id/a1a7e2b7-8f33-4313-baff-42e92ec14fd3%40oss.nttdata.com
<https://www.postgresql.org/message-id/a1a7e2b7-8f33-4313-baff-42e92ec14fd3%40oss.nttdata.com>

Attachment Content-Type Size
0001-Prevent-the-error-on-creating-a-dsm-segment-from-an-.patch application/octet-stream 4.4 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Hunaid Sohail 2025-01-14 07:57:29 Re: Psql meta-command conninfo+
Previous Message Shubham Khanna 2025-01-14 07:05:06 Re: Log a warning in pg_createsubscriber for max_slot_wal_keep_size