Re: Interrupting long external library calls

From: Simon Riggs <simon(at)2ndQuadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Sandro Santilli <strk(at)keybit(dot)net>, Florian Pflug <fgp(at)phlo(dot)org>, Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>, Mark Cave-Ayland <mark(dot)cave-ayland(at)ilande(dot)co(dot)uk>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Interrupting long external library calls
Date: 2012-05-26 10:40:11
Message-ID: CA+U5nML-6Vha63XAjiePM=aKNrdry+hPyCpvjSsvdLHX3q2fGw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 25 May 2012 17:34, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Sandro Santilli <strk(at)keybit(dot)net> writes:
>> I ended up providing an explicit mechanism to request interruption of
>> whatever the library is doing, and experimented (successfully so far)
>> requesting the interruption from a SIGINT handler.
>
>> Do you see any major drawback in doing so ?
>
> This seems a bit fragile.  It might work all right in Postgres, where
> we tend to set up signal handlers just once at process start, but ISTM
> other systems might assume they can change their signal handlers at
> any time.  The handler itself looks less than portable anyway ---
> what about the SIGINFO case?
>
> I assume that the geos::util::Interrupt::request() call sets a flag
> somewhere that's going to be periodically checked in long-running
> loops.  Would it be possible for the periodic checks to include a
> provision for a callback into Postgres-specific glue code, wherein
> you could test the same flags CHECK_FOR_INTERRUPTS does?  A similar
> approach might then be usable in other contexts, and it seems safer
> to me than messing with a host environment's signal handling.

Can we do that as a macro, e.g.

POSTGRES_LIBRARY_INTERRUPT_CHECK()

Otherwise the fix to this problem may be worse - faulty interrupt
handlers are worse than none at all.

--
 Simon Riggs                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Florian Pflug 2012-05-26 11:24:26 Re: Interrupting long external library calls
Previous Message Erik Rijkers 2012-05-26 09:21:34 FailedAssertion("!(PrivateRefCount[i] == 0)", File: "bufmgr.c", Line: 1741