From: Tom Lane <tgl@sss.pgh.pa.us>
To: Justin Pryzby <pryzby@telsasoft.com>
Cc: Michael Paquier <michael@paquier.xyz>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: Tomas Vondra <tomas.vondra@enterprisedb.com>
Cc: pgsql-hackers@postgresql.org
Subject: Re: should check interrupts in BuildRelationExtStatistics ?
Date: Tue, 05 Jul 2022 19:37:03 -0400
Message-ID: <2037431.1657064223@sss.pgh.pa.us> (raw)
In-Reply-To: <2031362.1657061281@sss.pgh.pa.us>
References: <20220509000108.GQ28830@telsasoft.com>
<YniLBN/x8N97ZDzf@paquier.xyz>
<3592964.1652067393@sss.pgh.pa.us>
<CA+TgmoY=Q9C9n=P=e8gTqLFTLza89t-cz+X-16LPaxq2+=qY2g@mail.gmail.com>
<20220603152837.GO29853@telsasoft.com>
<20220605014233.GR29853@telsasoft.com>
<Yp2rdhPtSHDJxPAd@paquier.xyz>
<20220617222549.GI29853@telsasoft.com>
<154878.1656717551@sss.pgh.pa.us>
<20220702000704.GJ13040@telsasoft.com>
<2031362.1657061281@sss.pgh.pa.us>
I wrote:
>>> I modestly propose the attached. I'm not sure if it's
>>> okay to back-patch this, because maybe someone out there
>>> is relying on qsort() to be incapable of throwing an error
I thought I'd better try to check that, and I soon found several
places that *are* relying on qsort() to not be any smarter than the
libc version. Notably, guc.c qsorts its persistent-state GUC array
during add_guc_variable --- an interrupt there would leave the GUC
data structure in an inconsistent state. There are lesser hazards,
typically memory leaks, elsewhere. So I fear this can't fly as-is.
Nonetheless, it'd be a good idea to use an interruptible sort in
as many places as we can. If we don't mind YA copy of the qsort
code, I'd be inclined to propose inventing qsort_interruptible
which is like qsort_arg but also does CHECK_FOR_INTERRUPTS.
(There seems no reason to support a non-arg version, since you
can just pass NULL.) Or we could redefine qsort_arg as allowing
interrupts, but that might still carry some surprises for existing
code.
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-hackers@postgresql.org
Cc: tgl@sss.pgh.pa.us, pryzby@telsasoft.com, michael@paquier.xyz, robertmhaas@gmail.com, tomas.vondra@enterprisedb.com
Subject: Re: should check interrupts in BuildRelationExtStatistics ?
In-Reply-To: <2037431.1657064223@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