Re: Interrupting long external library calls - Mailing list pgsql-hackers

From Heikki Linnakangas
Subject Re: Interrupting long external library calls
Date
Msg-id 4FB383C9.30402@enterprisedb.com
Whole thread Raw
In response to Interrupting long external library calls  (Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>)
Responses Re: Interrupting long external library calls
List pgsql-hackers
On 16.05.2012 13:25, Mark Cave-Ayland wrote:
> One of the issues we've been looking at with PostGIS is how to interrupt
> long-running processing tasks in external libraries, particularly GEOS.
> After a few tests here, it seems that even the existing SIGALRM handler
> doesn't get called if statement_timeout is reached when in an external
> library, e.g. with PostgreSQL 9.0/PostGIS 2.0 trunk/GEOS:

If you interrupt an external library call, it might leave memory in an 
inconsistent state, or some other such thing. It's not generally safe to 
interrupt arbitrary 3rd party code.

However, if you're absolutely positively sure that the library function 
can tolerate that, you can set "ImmediateInterruptOK = true" before 
calling it. See e.g PGSemaphoreLock() on how that's done before starting 
to sleep on a semapgore.

--   Heikki Linnakangas  EnterpriseDB   http://www.enterprisedb.com


pgsql-hackers by date:

Previous
From: Mark Cave-Ayland
Date:
Subject: Interrupting long external library calls
Next
From: Mark Cave-Ayland
Date:
Subject: Re: Interrupting long external library calls