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

From: Daniel Gustafsson <daniel(at)yesql(dot)se>
To: Rahila Syed <rahilasyed90(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>, Tomas Vondra <tomas(at)vondra(dot)me>
Subject: Re: Prevent an error on attaching/creating a DSM/DSA from an interrupt handler.
Date: 2025-04-11 10:23:53
Message-ID: 0ED39493-C8DF-4D12-AC96-A6828E489B04@yesql.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On 24 Mar 2025, at 20:31, Rahila Syed <rahilasyed90(at)gmail(dot)com> wrote:

> Please find the attached updated and rebased patch.

Thanks for this rebase, as was mentioned in the other thread I plan to get this
committed fairly soon. A few comments on the code, all performed in the
attached v3.

+ else
+ {
+ /* Log failure of unpinning */
+ elog(DEBUG2, "unable to unpin the segment %u as CurrentResourceOwner is NULL or releasing",
+ seg);
+ seg->resowner = NULL;
+ }
I removed the elog() calls since I can't see it adding enough value, and the
assignment to NULL can be removed as well since we've already asserted that
seg->resowner is NULL.

+ INJECTION_POINT("dsa_create_on_res_release");
This feels like a name which limits its use to this one test, whereas it is a
general purpose injection point. Renamed, and also moved to using dashes
rather than underscore as the former is project style.

+void
+test_dsa_inj(const char *name, const void *private_data)
Rather than duplicating the code I created an internal function for this test
which can be called from the existing basic test as well as this new test.

I also did a little bit of renaming to make it more readable.

As it can only really be tested with an injection point I plan on only
backpatching to 17 initially. Searching the archives I didn't find any mention
of this bug ever being hit so it seems safe to let it prove itself in testable
versions before going further back with it.

--
Daniel Gustafsson

Attachment Content-Type Size
v3-0001-Don-t-try-to-enlarge-resourceowner-when-releasing.patch application/octet-stream 8.6 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ranier Vilela 2025-04-11 11:27:23 Re: Silence resource leaks alerts
Previous Message Álvaro Herrera 2025-04-11 09:38:12 Re: merge file_exists_in_directory and _fileExistsInDirectory functions and move into common file dumputils.c