From: Tom Lane <tgl@sss.pgh.pa.us>
To: Eric Thinnes <e.thinnes@gmx.de>
Cc: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: Segmentation fault when calling BlessTupleDesc in a C function in parallel on PostgreSQL-(12.6, 12.7, 13.2, 13.3)
Date: Fri, 14 May 2021 11:20:35 -0400
Message-ID: <1885028.1621005635@sss.pgh.pa.us> (raw)
In-Reply-To: <105daf69-a864-2e83-1f93-a85e4ba80510@gmx.de>
References: <99aaa2eb-e194-bf07-c29a-1a76b4f2bcf9@gmx.de>
<CALj2ACV+SiO=xr0A3n13kRKVAgUjChu=4TxFKi8WOX4xxUvk3A@mail.gmail.com>
<105daf69-a864-2e83-1f93-a85e4ba80510@gmx.de>
Eric Thinnes <e.thinnes@gmx.de> writes:
> The function always delivers the same result with the same call
> parameters except for the determination of the result types and the
> generation of the TupleDesc, the function has no side effects.
BlessTupleDesc certainly has side effects; that's pretty much the
whole point of it. If you're marking this thing as parallel safe,
I imagine that the problem boils down to "parallel worker locally
registers a blessed tupdesc, but the leader has never heard of it,
so fails to interpret the returned tuple".
Perhaps a workaround is possible by using a named composite type
instead of generating a rowtype on the fly? But that won't work
if you want this to be polymorphic.
Also, I recall that there are provisions in typcache.c in recent
versions to support a shared pool of registered (i.e. blessed)
tuple descriptors. That would likely solve your problem, but
I've never looked into how to use that code. I doubt just
calling BlessTupleDesc is enough. In particular, I imagine
you need to make sure the leader process creates the tupdesc
first, so it's available to all workers.
regards, tom lane
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 using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, e.thinnes@gmx.de, bharath.rupireddyforpostgres@gmail.com, pgsql-bugs@lists.postgresql.org
Subject: Re: Segmentation fault when calling BlessTupleDesc in a C function in parallel on PostgreSQL-(12.6, 12.7, 13.2, 13.3)
In-Reply-To: <1885028.1621005635@sss.pgh.pa.us>
* 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