putting CHECK_FOR_INTERRUPTS in qsort_comparetup() - Mailing list pgsql-patches

From Charles Duffy
Subject putting CHECK_FOR_INTERRUPTS in qsort_comparetup()
Date
Msg-id dfdaea8f0607110025p43c6b96ahfa95d02ed7ba3af5@mail.gmail.com
Whole thread Raw
Responses Re: putting CHECK_FOR_INTERRUPTS in qsort_comparetup()
List pgsql-patches
Hi,

We came up with this patch in response to a problem reported to us by a
client. They had a query which took an unacceptably long time to respond
to a cancel request (SIGINT). The client uses 8.1.4, so the patch is
against that.

Their work_mem setting was rather large (1000000). We determined that when it
received SIGINT, the backend was always inside qsort(), so it wouldn't
call ProcessInterrupts() again until it finished this large in-memory
sort. Upon entering tuplesort_performsort(), state->memtupcount was
29247.

The patch puts a CHECK_FOR_INTERRUPTS in qsort_comparetup. This solves
their problem, at the cost of checking InterruptPending a lot. The
"unlikely()" gcc directive might help there a bit.

I'm not sure if this patch has general applicability - but it seems to
solve the problem for our client. Does anyone think it might introduce
any new problems?

Thanks,


--
Charles Duffy

Attachment

pgsql-patches by date:

Previous
From: James Gates
Date:
Subject: Patch to "configure" to enable PostgreSQL build with Kerberos 5 on Solaris 11
Next
From: Tom Lane
Date:
Subject: Re: Patch to "configure" to enable PostgreSQL build with Kerberos 5 on Solaris 11