Re: should check interrupts in BuildRelationExtStatistics ?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Justin Pryzby <pryzby(at)telsasoft(dot)com>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, Robert Haas <robertmhaas(at)gmail(dot)com>, Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: should check interrupts in BuildRelationExtStatistics ?
Date: 2022-07-05 23:37:03
Message-ID: 2037431.1657064223@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2022-07-05 23:38:55 Re: should check interrupts in BuildRelationExtStatistics ?
Previous Message Andres Freund 2022-07-05 23:20:13 Re: should check interrupts in BuildRelationExtStatistics ?